1. Delete the original MariaDB, otherwise MySQL cannot be installed
mariadb-libs-5.5.52-1.el7.x86_64 rpm -qa|grep mariadb rpm -e --nodeps mariadb-libs
1. In https://dev.mysql.com/downloads/mysql/ Select Red Hat Enterprise Linux 7 / Oracle Linux 7, and select OS version as all.
mysql-5.7.21-1.el7.x86_64.rpm-bundle.tarAll the RPM packages are in it
rpm -ivh mysql-community-common-5.7.21-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-5.7.21-1.el7.x86_64.rpm rpm -ivh mysql-community-devel-5.7.21-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-compat-5.7.21-1.el7.x86_64.rpm rpm -ivh mysql-community-client-5.7.21-1.el7.x86_64.rpm rpm -ivh mysql-community-server-5.7.21-1.el7.x86_64.rpm
So far, all the files of mysql5.7 have been installed, and the next step is to start the service test.
1. First, close the MySQL service
service mysqld stop
2. Then modify the configuration file:
3. Add a code to login MySQL with empty password
# Disabling symbolic-links is recommended to prevent assorted security risks Skip grant tables ා add this sentence. At this time, you don't need a password to log in to MySQL symbolic-links=0
4. Start MySQL service:
service mysqld start
5. Login MySQL with empty password:
MySQL - U root - P # enter the command and press enter. When the password prompt appears, press enter directly
6. Set MySQL password:
mysql> set password for [email protected] = password('123456'); ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement MySQL > flush privileges; # update permissions Query OK, 0 rows affected (0.00 sec) mysql> set password for [email protected] = password('123456'); Query OK, 0 rows affected, 1 warning (0.00 sec) MySQL > flush privileges; # update permissions MySQL > quit; # exit Service mysqld stop # stop the MySQL service and restore the MySQL configuration vim /etc/ my.cnf #Modify configuration file # Disabling symbolic-links is recommended to prevent assorted security risks #Skip grant tables symbolic-links=0 Service mysqld start # start the MySQL service MySQL - uroot - P # enter new password to login
7. Set Mysql to boot automatically:
systemctl enable mysqld
The above is a tutorial of offline installation of MySQL for centos7 introduced by Xiaobian. I hope it can help you. If you have any questions, please leave me a message and Xiaobian will reply you in time. Thank you very much for your support to developer!
If you think this article is helpful to you, please reprint, please indicate the source, thank you!