1、 Install YUM Repo
Starting from CentOS 7, use MariaDB to replace the default MySQL. Since there is no mysql in the yum source of CentOS7, you need to download the yum repo configuration file from the mysql website.
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
Then install the repo:
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
After the execution is complete, two repo files mysql-community.repo``mysql-community-source.repo
will be generated in the /etc/yum.repos.d/
directory
2、 Install MySQL
Use the yum command to complete the installation
yum install mysql mysql-server mysql-devel
**Start msyql: **
systemctl start mysqld #Start MySQL
Configure MySQL
Get the temporary password during installation:
grep 'temporary password'/var/log/mysqld.log
log in:
mysql -u root -p
Change the password after successful login:
set password=password("yourpassword");
Set security options:
mysql_secure_installation
other settings:
systemctl stop mysqld #Close MySQL
systemctl restart mysqld #Restart MySQL
systemctl status mysqld #View MySQL running status
systemctl enable mysqld #Set boot up
systemctl disable mysqld #Turn off startup
Turn on remote control
MySQL does not enable remote control by default, you must add remote access users
grant all privileges on database name.Table name to created user name(root)@"%" identified by "password"; #data storage name.If the table name is written*.*Representative authorizes all databases
flush privileges; #Refresh the content just now
# Such as:
grant all privileges on *.* to root@"113.64.243.1" identified by "123456789";
@ The following is the client IP address (or host name) that accesses mysql.% represents any client. If localhost is filled in for local access (then this user cannot remotely access the mysql database).
At the same time, you can also set whether to have remote access permissions for existing users.
**Configure the default encoding as utf8: **
vi /etc/my.cnf
# Add to
[ mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
**Other default configuration file path: **
Configuration file:/etc/my.cnf
Log file:/var/log//var/log/mysqld.log
Service startup script:/usr/lib/systemd/system/mysqld.service
Socket file:/var/run/mysqld/mysqld.pid
Recommended Posts