CentOS7 Offline Installation of MySQL Tutorial Explanation

  • 2021-12-11 09:24:34
  • OfStack

1. Delete the original mariadb, otherwise mysql will not fit in


mariadb-libs-5.5.52-1.el7.x86_64
rpm -qa|grep mariadb
rpm -e --nodeps mariadb-libs

1. Select Red Hat Enterprise Linux 7/Oracle Linux 7 at https://dev. mysql. com/downloads/mysql/, and select the version of os as all.

Direct download mysql-5.7.21-1.el7.x86_64.rpm-bundle.tar All the rpm packages are inside


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

At this point, all the files of mysql 5.7 are installed, and the next step is to start the service test.

1. Shut down the mysql service first:

service mysqld stop

2. Then modify the configuration file:

vim /etc/my.cnf

3. Next, add a code to log in to mysql with an empty password:


# Disabling symbolic-links is recommended to prevent assorted security risks
skip-grant-tables   # Add this sentence and log in at this time mysql You don't need a password 
symbolic-links=0

4. Turn on the mysql service:

service mysqld start

5. Login to mysql with an empty password:

mysql -u root -p    #输入命令回车进入,出现输入密码提示直接回车

6. Set the mysql password:


mysql> set password for root@localhost = 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 root@localhost = password('123456'); 
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>flush privileges; # Update permissions 
mysql>quit; # Quit 
service mysqld stop #  Stop mysql Services ,  Recovery mysql Configure 
vim /etc/my.cnf   # Modify the configuration file 
# Disabling symbolic-links is recommended to prevent assorted security risks
# skip-grant-tables #  Comment out this sentence 
symbolic-links=0
service mysqld start #  Start mysql Services 
mysql -uroot -p #  Enter a new password to log in 

7. Set mysql to boot and start:

systemctl enable mysqld

Summarize


Related articles: