当前位置:网站首页>Linux Yum install MySQL

Linux Yum install MySQL

2022-07-06 11:49:00 @Little snail

Be careful : Only need master Node installation mysql
First loading mysql Source , Put it on again mysql

Catalog

2.1 Switch root user ( password :zkpk)

[[email protected] ~]# su root

2.2 View and uninstall the system's own mariadb-lib database

[[email protected] zkpk]# rpm -qa|grep mariadb
mariadb-libs-5.5.56-2.el7.x86_64
[[email protected] zkpk]# yum -y remove mariadb-libs-*

2.3 add to MySQL yum Source

Be careful : This step requires networking

2.3.1 download mysql Source installation package

[[email protected] zkpk]# wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

2.3.2 install mysql Source

[[email protected] zkpk]# yum -y localinstall mysql57-community-release-el7-8.noarch.rpm

2.3.3 Check mysql Source installed successfully

[[email protected] zkpk]# yum repolist enabled | grep "mysql.*-community.*"

 Insert picture description here

2.4 install MySQL

Be careful : install mysql On the server side , The client is automatically installed as a dependency

[r[email protected] zkpk]# yum -y install mysql-community-server

 Insert picture description here

2.5 start-up MySQL service

2.5.1 command

[[email protected] zkpk]# systemctl start mysqld

2.5.2 see MySQL Start state of ( Green appears in the figure running Words indicate success )

[[email protected] zkpk]# systemctl status mysqld

 Insert picture description here

2.6 Set boot up

[[email protected] zkpk]# systemctl enable mysqld
# Reload the  systemd, Scan for new or changed units 
[[email protected] zkpk]# systemctl daemon-reload

2.7 modify root Default password

2.7.1 see mysql Install the generated random default password (/var/log/mysqld.log In file )

[[email protected] zkpk]# grep 'temporary password' /var/log/mysqld.log

 Insert picture description here

2.7.2 Sign in mysql( The password is marked in the red box above )

[[email protected] zkpk]# mysql -uroot -p

2.7.3 modify mysql The password for “MyNewPass4!”( Suggest the first )

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
 perhaps :
mysql> set password for 'root'@'localhost'=password('MyNewPass4!');

Be careful :mysql5.7 The password security check plug-in is installed by default (validate_password), The default password checking policy requires that the password must contain : Case letters 、 Numbers and special symbols , And the length cannot be less than 8 position . Otherwise, it will prompt ERROR
1819 (HY000): Your password does not satisfy the current policy
requirements error , As shown in the figure below :

 Insert picture description here

2.8 modify mysql Password policy

2.8.1 see msyql Information about password policy ; sign out mysql Command line

mysql> show variables like '%password%';
mysql> exit;

 Insert picture description here

2.8.2 Turn off password policy

2.8.2.1 Ban mysql Password policy , towards my.cnf Add the following configuration at the end of the file (/etc/my.cnf), preservation 、 sign out

[[email protected] zkpk]# vim /etc/my.cnf
validate_password = off

2.8.2.2 Restart mysql Service makes configuration effective :

[[email protected] zkpk]# systemctl restart mysqld

2.9 modify root The password for zkpk

2.9.1 Sign in mysql( password :MyNewPass4!)

[[email protected] zkpk]# mysql -uroot -p

2.9.2 modify mysql Of root User password is zkpk( Suggest the first )

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'zkpk';
 perhaps 
mysql> set password for 'root'@'localhost'=password('zkpk');

2.10 add to zkpk Users and give remote login permission , And then quit mysql Command line

mysql>grant all on *.* to [email protected]'%' identified by 'zkpk'; 
mysql>grant all on *.* to [email protected]'localhost' identified by 'zkpk'; 
mysql>grant all on *.* to [email protected]'master' identified by 'zkpk'; 
mysql>flush privileges;
mysql>exit;

2.11 The configuration default code is utf8

2.11.1 modify /etc/my.cnf The configuration file , stay [mysqld] Add coding configuration , That is, the red box in the following figure ; preservation 、 sign out

[[email protected] zkpk]# vim /etc/my.cnf
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'

 Insert picture description here

2.11.2 Restart mysql service

[[email protected] zkpk]# systemctl restart mysqld

2.11.3 View the database default encoding

2.11.3.1 Sign in mysql( password :zkpk)

[[email protected] zkpk]# mysql -uroot -p

2.11.3.2 View encoding ; And then quit mysql Command line

mysql> show variables like '%character%';
mysql> exit;

 Insert picture description here

2.12 Check if the firewall is turned off

2.12.1 Carry out orders ; If the lower red box appears dead word , Explain that the firewall is off

[[email protected] zkpk]# systemctl status firewalld

 Insert picture description here

2.12.1 If the firewall is not turned off , Follow these steps . Remote access open firewall mysql Of 3306 port

[[email protected] zkpk]# firewall-cmd --add-port=3306/tcp

 Insert picture description here

2.13MySQL Several important catalogues of

 The configuration file :/etc/my.cnf
 Log files :/var/log/mysqld.log
 Service startup script :/usr/lib/systemd/system/mysqld.service 
socket file :/var/run/mysqld/mysqld.pid
 Database directory  /var/lib/mysql/
 The configuration file  /usr/share/mysql(mysql.server Commands and configuration files )
 Relevant command  /usr/bin(mysqladmin mysqldump Wait for the order )
 The startup script  /etc/rc.d/init.d/( Start script file mysql The catalog of )
原网站

版权声明
本文为[@Little snail]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060913090354.html