Install and configure MySQL8 on CentOS7


Official website Product Documentation

Add REPO file

Use vi or vim to edit the /etc/yum.repos.d/mysql-community.repo file, copy the following content to the file, then save and exit.

name=MySQL 8.0 Community Server

Perform installation

            yum -y install mysql-community-server

Modify the configuration file

Use vi or vim to edit /etc/my.cnf. As MySQL8 compared with the previous version, the default processing methods of login, SQL statement rigor and insufficient field length have changed, so if we need to keep the same as before, do the following configuration. If you do not need to be compatible with the old program, you can ignore it. In the modified configuration of the following example, the first three items are for compatibility with the usage habits of the old version, and the last item is to modify the default storage directory of the database.


Start service

            systemctl enable mysqld
systemctl start mysqld

Get the default connection password

The login password of MySQL8 native root is stored in the log file, and we need to check it from the log file.

            grep "password" /var/log/mysqld.log

Verification Service

So far our installation and configuration have been completed, we use the command line to connect to the MySQL service, and then create a database and account.

            mysql -uroot -p