Home  >  Article  >  Database  >  How to install mysql 5.7.26 on centOS7.4

How to install mysql 5.7.26 on centOS7.4

WBOY
WBOYforward
2023-05-28 15:25:061157browse

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

centOS7.4安装mysql 5.7.26的方法

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

centOS7.4安装mysql 5.7.26的方法

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:

centOS7.4安装mysql 5.7.26的方法

The reason is because mysql has The specifications for password setting are specifically related to the value of validate_password_policy:

centOS7.4安装mysql 5.7.26的方法

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete