Centos7.6 offline installation mysql

Download mysql-5.7.37-1.el7.x86_64.rpm-bundle.tar

Network disk address: Link: https://pan.baidu.com/s/1Xw2IjWHpKWyELoxmFs2wOg?pwd=1024 
Extraction code: 1024

Create an installation directory

mkdir -p /opt/hstech/tool

Upload mysql-5.7.37-1.el7.x86_64.rpm-bundle.tar to the tool directory

Unzip the installation package:

tar -xvf mysql-5.7.37-1.el7.x86_64.rpm-bundle.tar

As shown below:

Execute the installation

rpm -Uvh *.rpm --nodeps --force

As shown below:

 Configure the default encoding as utf8

Modify the /etc/my.cnf configuration file and add encoding configuration under [mysqld], as follows:

vim /etc/my.cnf
character_set_server=utf8 
init_connect='SET NAMES utf8'
lower_case_table_names=1 #不区分大小写

 

 After editing and saving, restart the mysql service;

systemctl restart mysqld

Start the mysql service

service mysqld start

 As shown below:

 vim /var/log/mysqld.log

Enter the command mode , enter / password, and retrieve the position as shown in the figure, which is the default password of mysql: A temporary password is generated for root@localhost: Oc7iXDmO2w#i

 

 Modify the default password

mysql -u root -p

As shown below:

 Enter the temporary password to enter the MySQL command line:

Successful login, as shown below:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'Jie@1234';

 Change the password to Jie@1234 (Note that the default password policy of mysql5.7 requires that the password must be a combination of uppercase and lowercase letters, numbers and special letters, at least 8 characters)

 Set to allow remote login

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

Version 8.0 and above

use mysql;
update user set host='%' where user='root';
flush privileges;

As shown below:

 then log out

exit;

The firewall opens port 3306;

firewall-cmd --zone=public --add-port=3306/tcp --permanent

As shown below:

 reload firewall

firewall-cmd --reload

As shown below:

Check whether the mysql service is started:

ps -ef|grep mysql

Started as shown below:

 Set up autostart

systemctl enable mysqld

View startup items

systemctl list-unit-files | grep enable

Guess you like

Origin blog.csdn.net/jieyongquan/article/details/129584089