Install MySQL on a standalone server

Standalone MySQL installation procedure

Download a MySQL installation package

  1. Download a MySQL installation package from https://dev.mysql.com/downloads/mysql/ according to your requirements.

Figure-1 Downloading MySQL

 

  1. Transmit the installation package to the target VM and uncompress it.

Figure-2 Uncompressing the installation package

 

Uninstall an old MySQL version

Skip this task if your environment does not has an old MySQL version installed.

To uninstall MySQL:

  1. View the MySQL version.

  1. Delete MySQL components in the correct sequence.

Install MySQL components

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

Start the MySQL service

  1. Execute the systemctl start mysqld.service command.

  1. Execute the systemctl enable mysqld.service command to enable MySQL to run on startup.

Create a MySQL password

  1. Obtain the temporary password.

  1. Execute the grep 'temporary password' /var/log/mysqld.log command.

[root@localhost ~]# grep 'temporary password' /var/log/mysqld.log

  1. 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.

  1. Log in to MySQL with the temporary password.

  1. Execute the [root@localhost ~]# mysql -uroot -p command.

  1. Execute the Enter password:   # command to enter the password.

  1. Execute the mysql> quit      # command to log out.

  1. 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)

 

  1. Enable remote management.

  1. Enable remote access for the root user.

mysql> grant all privileges on *.* to root@'%' identified by ' root ';

  1. Flush privileges.

mysql> flush privileges;