Centos7 Mysql offline installation

1. Download mysql

https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.30-1.el7.x86_64.rpm-bundle.tar

2. View and delete mariadb in the machine

# rpm -qa | grep mariadb
# rpm -qa | grep mariadb |xargs yum remove -y

3. Find and delete mysql residual files

# find / -name mysql

Delete the found mysql related files and directories

# rm -rf /var/lib/mysql
# rm -rf /var/log/mysqld.log
# rm -rf /var/log/mysql.log

4. Put the downloaded file  mysql-5.7.30-1.el7.x86_64.rpm-bundle.tar in the installation directory and unzip it

# tar -xvf mysql-5.7.30-1.el7.x86_64.rpm-bundle.tar

5. Install the decompressed RPM packages in sequence (Note: You must install them in sequence, otherwise the installation will fail due to lack of dependencies)

#rpm -ivh mysql-community-common-5.7.30-1.el7.x86_64.rpm
#rpm -ivh mysql-community-libs-5.7.30-1.el7.x86_64.rpm
#rpm -ivh mysql-community-devel-5.7.30-1.el7.x86_64.rpm
#rpm -ivh mysql-community-libs-compat-5.7.30-1.el7.x86_64.rpm
#rpm -ivh mysql-community-client-5.7.30-1.el7.x86_64.rpm
#rpm -ivh mysql-community-server-5.7.30-1.el7.x86_64.rpm

6. Modify the mysql configuration file and edit the /etc/my.cnf file according to your needs 

# vim /etc/my.cnf

7. Set Mysql to start automatically after booting

# sudo systemctl enable mysqld

8. Start mysql

# systemctl start mysqld

9. Check the startup status and open ports are normal

# systemctl status mysqld
# netstat -plntu | grep 3306

10. Find the temporary password after installation (note: if the temporary password is not found, the installation failed, please refer to the appendix below)

# sudo grep 'temporary password' /var/log/mysqld.log

11. Configure Mysql security policy

# mysql_secure_installation

Enter the above temporary password according to the prompts, and set a new password, as follows:

[...]
Enter current password for root (enter for none):
OK, successfully used password, moving on...
[...]
Set root password? [Y/n] Y
New password:
Re-enter new password:
Remove anonymous users? [Y/n] Y
[...]
Disallow root login remotely? [Y/n] N
[...]
Remove test database and access to it [Y/n] Y
[...]
Reload privilege tables now? [Y/n] Y
All done!

12.Log in to Mysql 

# mysql -u root -p

Enter the password and enter successfully, indicating that the installation is successful.

13. Turn on remote access permissions

Run the following command after logging in to mysql

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;

 

appendix:

If the temporary password is not found after the installation, the installation has failed. After uninstalling, delete the relevant directory and reinstall:

# yum remove mysql-community-server
# rm  -rf /var/lib/mysql

Enter the mysql decompression directory and reinstall:

# rpm -ivh mysql-community-server-5.7.30-1.el7.x86_64.rpm

Then look for the temporary password.

 

Attached online installation tutorial:

https://blog.csdn.net/abcdu1/article/details/87367656

 

reference:

https://stackoverflow.com/questions/40561251/no-temporary-password-in-mysqld-log

Guess you like

Origin blog.csdn.net/abcdu1/article/details/109864782