Recently, the prodigal son tried to use Mycat to do the read and write separation and table and library of MySQL, so several virtual machines were set up to do the operation. Without further ado, we are now installing MySQL on centos7.

It is said that installing MySQL with yum on centos7 will fail, so I will install MySQL manually.

Download the required installation package

I choose the domestic Huawei mirror, the speed is faster. Download four RPM packages of Common LiBS Client Server. The MySQL version can be selected in huawei image. I chose MySQL5.7.

Wget wget HTTP: / / https://mirrors.huaweicloud.com/mysql/Downloads/MySQL-5.7/mysql-community-common-5.7.30-1.el6.i686.rpm https://mirrors.huaweicloud.com/mysql/Downloads/MySQL-5.7/mysql-community-libs-5.7.30-1.el6.x86_64.rpm wget https://mirrors.huaweicloud.com/mysql/Downloads/MySQL-5.7/mysql-community-client-5.7.30-1.el6.x86_64.rpm wget https://mirrors.huaweicloud.com/mysql/Downloads/MySQL-5.7/mysql-community-server-5.7.30-1.el6.x86_64.rpmCopy the code

Install four RPM packages in sequence

Remember to install in sequence because packages have dependencies.

RPM -ivh mysql-community-libs-5.7.30-1.el6.x86_64. RPM --force --nodeps RPM -ivh RPM --force --nodeps RPM -ivh mysql-community-client-5.7.30-1.el6.x86_64. RPM --force --nodeps RPM -ivh mysql-community-server-5.7.30-1.el6.x86_64. RPM --force --nodeps RPM -ivh mysql-community-server-5.7.30-1.el6.x86_64Copy the code

Nodeps = force nodeps = force nodeps = force nodeps = force nodeps

[root@localhost mysql]# RPM -ivh mysql-community-libs-5.7.30-1.el6.x86_64. RPM Mysql-community-libs-5.7.30-1.el6.x86_64. RPM: V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY error: dependency check failed: mysql-community-common(x86-64) >= 5.7.9 required by mysql-community-libs-5.7.30-1.el6.x86_64Copy the code

Therefore, it is recommended to add parameters to the installation.

Start the MySQL

service mysqld start
Copy the code

Changing the Initial Password

After MySQL is installed by default, the password is recorded in the log. You can view the initial password with this command:

cat /var/log/mysqld.log |grep password
Copy the code

You should see something like this:

Log on to the MySQL

Run the following command to log in to MySQL:

mysql -uroot -p 
Copy the code

Enter the password found above.

Change the root login password

After logging in to MySQL, run the following command to change the password:

set password = password('123456'); Flush PRIVILEGES;Copy the code

Sometimes this command will fail because your password is too simple. You can solve this problem in either of the following ways :(complex passwords are recommended in formal environments.)

  1. Set a complicated password

  2. To reduce password verification strength, use the following commands:

    Set global validate_password_policy=0; Set global validate_password_length=4; Flush PRIVILEGES; Then execute the set password command aboveCopy the code

Enjoy it