Mariadb is installed by default in centos. This is a branch of mysql. However, for needs, mysql still needs to be installed in the system, and after the installation is completed, mariadb can be directly overwritten.
1 Download and install the official mysql yum repository
[root@localhost ~]# wget -i -c
Use the above command directly Downloaded the yum repository for installation, which is about 25kb, and then you can install it directly with yum.
[root@localhost ~]# yum -y install mysql57-community-release-el7-10.noarch.rpm
Then start installing the mysql server.
[root@localhost ~]# yum -y install mysql-community-server
This step may take some time. After the installation is completed, the previous mariadb will be overwritten.
2 mysql database settings
First start mysql
[root@localhost ~]# systemctl start mysqld.service
Check the mysql running status, the running status is as shown in the figure:
[root@localhost ~]# systemctl status mysqld.service
Mysql has started to run normally at this time, but if you want to enter mysql, you must first find out the password of the root user at this time. You can find the password in the log file through the following command:
[root@localhost ~]# grep "password" /var/log/mysqld.log
The following command enters the database:
[root@localhost ~]# mysql -uroot -p
Enter the initial password. You cannot do anything at this time because mysql must change the password by default before operating the database:
mysql> alter user 'root'@'localhost' identified by 'new password';
Password setting 12 digits
There is a problem here. When setting a new password, if the setting is too simple, an error will be reported:
The reason is because mysql has The specifications for password setting are specifically related to the value of validate_password_policy
:
After setting the password, you are done
The above is the detailed content of How to install mysql 5.7.26 on centOS7.4. For more information, please follow other related articles on the PHP Chinese website!