centos7 Summary of pits encountered in installing mysql and mysqlclient

  • 2021-07-01 08:39:44
  • OfStack

1. Add an MySQL Yum source

MySQL official website > DOWNLOADS > MySQL Yum Repository Find the appropriate version of yum source


$wget https://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm
$sudo rpm -Uvh mysql80-community-release-el7-2.noarch.rpm
 
# View MySQL Database version information 
$yum repolist all | grep mysql

2. Choose the installation version

Modify the/etc/yum. repos. d/mysql-community. repo to select MySQL version 5.7


# Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/
enabled=0 #  Prohibit 
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
 
# Enable to use MySQL 5.7
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1 #  Installation 
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
 
[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/
enabled=0 #  Prohibit 
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

Step 3 Install


# Execute the following command to install MySQL
yum install mysql-community-server
# Start mysql ( CentOS7 Middle) 
systemctl start mysqld.service
# Lower versions of the operating system can use the following instructions 
service mysqld start
# View MySQL Status 
systemctl status mysqld.service
# The following instructions are available for lower versions of operating systems 
service mysqld status

4. View and change passwords


$grep "password" /var/log/mysqld.log
2019-04-11T08:17:16.706096Z 1 [Note] A temporary password is generated for root@localhost: ux#bkaM(k1q-
$mysql -u root -p
>ux#bkaM(k1q-
 
#  Change password 
mysql>ALTER USER 'root'@'localhost' IDENTIFIED BY 'complex password';
mysql>set global validate_password_policy=0;
mysql>set global validate_password_length=1;
mysql>ALTER USER 'root'@'localhost' IDENTIFIED BY 'simple password';

5. Configure open port 3306

The authorization method allows any host to access the mysql server: "1. Just use this, and restrict port access to firewalld."


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

Restrict ip access:


mysql>GRANT ALL PRIVILEGES ON *.* TO 'jack'@'10.10.50.127' IDENTIFIED BY 'password' WITH GRANT OPTION;

The above is the centos7 installation of mysql and mysqlclient encountered 1 pit and need to pay attention to the knowledge points summary, thank you for reading and support for this site.


Related articles: