Download a MySQL installation package from https://dev.mysql.com/downloads/mysql/ according to your requirements.
Figure-1 Downloading MySQL
Transmit the installation package to the target VM and uncompress it.
Figure-2 Uncompressing the installation package
Skip this task if your environment does not has an old MySQL version installed.
To uninstall MySQL:
View the MySQL version.
Delete MySQL components in the correct sequence.
Execute the following commands in sequence.
rpm -ivh mysql-community-common-5.7.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.26-1.el7.x86_64.rpm
Execute the systemctl start mysqld.service command.
Execute the systemctl enable mysqld.service command to enable MySQL to run on startup.
Obtain the temporary password.
Execute the grep 'temporary password' /var/log/mysqld.log command.
[root@localhost ~]# grep 'temporary password' /var/log/mysqld.log
Search for temporary password in /var/log/mysqld.log.
2019-07-06T08:52:01.624650Z 1 [Note] A temporary password is generated for root@localhost: kfyHk8(-Iwo7
kfyHk8(-Iwo7 is the temporary password.
Log in to MySQL with the temporary password.
Execute the [root@localhost ~]# mysql -uroot -p command.
Execute the Enter password: # command to enter the password.
Execute the mysql> quit # command to log out.
Execute the following commands to modify the MySQL root password.
mysql> alter user root@localhost identified by 'sdbrk';
mysql> set password for root@localhost=password('sdbrk');
If the password does not meet the password strength requirements, the system displays ERROR 1819 (HY000): Your password does not satisfy the current policy requirements. To resolve this problem: 1. Execute the validate_password_policy=0; command to change the password policy. mysql> set global validate_password_policy=0; # The policy requires a password to contain eight or more characters. 2. Modify the valid password length: mysql> set global validate_password_length=1; Query OK, 0 rows affected (0.00 sec) The minimum password length is 4. If you set the password length to be smaller than 4, the value 4 takes effect. 3. Modify the password. mysql> set password for root@localhost=password(' root '); Query OK, 0 rows affected, 1 warning (0.00 sec) |
Enable remote management.
Enable remote access for the root user.
mysql> grant all privileges on *.* to root@'%' identified by ' root ';
Flush privileges.