mysql5.7 is manually installed on centos server

Keywords: Linux Database MySQL CentOS server

Manually install MySQL version 5.7. X in CentOS 7.4 environment.

1. Install MySQL version: 5.7.25

2. Download address

https://dev.mysql.com/downloads/mysql/5.7.html#downloads

(as time goes by, please refer to the download address of the latest official website)

3. Use the wget command to download the relevant rpm files through breakpoint transmission (or directly download them on windows and upload them to linux)

https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-common-5.7.25-1.el7.x86_64.rpm

https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-libs-5.7.25-1.el7.x86_64.rpm

https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-devel-5.7.25-1.el7.x86_64.rpm

https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-client-5.7.25-1.el7.x86_64.rpm

https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-server-5.7.25-1.el7.x86_64.rpm

4. After downloading, enter the corresponding directory for installation in turn

(Note: there is a sequence of installation. Just install according to the above download sequence)

rpm -ivh mysql-community-common-5.7.25-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-libs-5.7.25-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-devel-5.7.25-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-client-5.7.25-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-server-5.7.25-1.el7.x86_64.rpm --force --nodeps

(Note: among them – force --nodeps should be added appropriately according to the situation. Otherwise, some machine installation will be abnormal)
(uninstall the code if there is a problem)

#Find mysql installed under linux
rpm -qa | grep -i mysql
rpm -e mysql-community-common-5.7.25-1.el7.x86_64.rpm
rpm -e mysql-community-libs-5.7.25-1.el7.x86_64.rpm
rpm -e mysql-community-devel-5.7.25-1.el7.x86_64.rpm
rpm -e mysql-community-client-5.7.25-1.el7.x86_64.rpm
rpm -e mysql-community-server-5.7.25-1.el7.x86_64.rpm
//You can add the parameter nodeps to force deletion, but it is generally not recommended because programs that depend on the software package may not run

5. After installation, you need to start the service first.

(note that the service startup of CentOS7 and above is different from that of 6)

systemctl start mysqld

6. Confirm that the installation is successful and create the initial root administrator password

Change to / etc/my.cnf

vim /etc/my.cnf

Add in [mysqld]

skip-grant-tables=1

This line of configuration allows mysqld to start without verifying the password

7. Restart mysqld service

systemctl restart mysqld

8. Change the login password of root

1) Log in to mysql using root

mysql -uroot -p (Search directly and press enter. The password is blank)

2) Switch database

use mysql;

3) Upgrade user table

update user set authentication_string = password('Your password'), password_expired = 'N', password_last_changed = now() where user = 'root';

(after setting the password for root, edit the etc/my.conf file and comment out the configuration skip grant tables = 1)

//Edit file
vim /etc/my.cnf
//Comment out the documents inside
#skip-grant-tables=1
//Restart service
systemctl restart mysqld

9. After the password is changed successfully, you can log in to mysql to set the client connection.

(Note: if it is not set, the client Navicat cannot connect)

//Authorize remote connection permissions
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Your password' WITH GRANT OPTION;
flush privileges;

Refresh table data

flush privileges;

sign out

10. Set the MySQL encoding to prevent garbled code. Under [mysqld], add the encoding method

character-set-server=utf8

(see the attached document for details)

11. Restart MySQL service

systemctl restart mysqld

After you can connect to the database through client software, such as Navicat for MySQL, congratulations on the successful installation.

[FAQ]

1. The service cannot be started when it is installed under the server CentOS in Hong Kong.

[root@syne-hk-test mysql-5.7]# systemctl start mysqld

Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

After in-depth investigation, the reason is that libaio.so.1 is not installed. Just install it.

yum install libaio

2,ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
It will appear when logging in to view the database. It needs to be changed to a secure password

alter user user() identified by 'root123';

2.1,ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
The password is too simple. Change it to a more secure password.

Sometimes after installing and modifying the password, the library is missing. I don't know why. Tencent cloud has problems. I'll add it later

Posted by LiamOReilly on Sat, 23 Oct 2021 18:58:50 -0700