mysql5.7 rpm MySQL installation details

mysql5.7 rpm MySQL installation details

First, check the linux operating system version and system kernel version

[root@nfs_client ~]# Cat / etc / RedHat release to view the operating system version
CentOS Linux release 7.5.1804 (Core) 
[root@nfs_client ~]# uname -r view system kernel version
3.10.0-862.el7.x86_64

2. Download the MySQL installation file of the corresponding version

1. Download address; https://dev.mysql.com/downloads/mysql/

2,Select the corresponding Linux Version and x86/x64 Download

You can select RPM Bundle. Remember to unzip tar - xvf XXX after downloading tar

[root@nfs_client ~]# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.22-1.el7.x86_64.rpm-bundle.tar

3. Uninstall the old version of MySql (if not, skip this step)

1. View the old version of MySql

 ```bash

rpm -qa | grep mysql
```

2. Delete the old components one by one

Use the command RPM - E -- nodeps {- file name} to remove. There may be dependencies during removal. Pay attention to a certain order.

rpm -e --nodeps mysql-community-libs-5.7.35-1.el7.x86_64.rpm

IV. install MySql components using rpm command

Use the command RPM - IVH {- file name} to install.

Install the rpm package according to the dependencies. The dependencies are common → libs → client → server

rpm -ivh mysql-community-common-5.7.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.22-1.el7.x86_64.rpm

Note: in ivh, i-install is installed; v-verbose progress bar; h-hash hash check

Install mysql-community-libs-5.7.22-1 el7. x86_ An error may be reported at 64.rpm: MySQL dependency error

[root@nfs_client tools]# rpm -ivh mysql-community-libs-5.7.22-1.el7.x86_64.rpm
warning: mysql-community-libs-5.7.22-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
        mysql-community-common(x86-64) >= 5.7.9 is needed by mysql-community-libs-5.7.22-1.el7.x86_64
        mariadb-libs is obsoleted by mysql-community-libs-5.7.22-1.el7.x86_64

Solution: clear all mysql dependent packages in yum

[root@nfs_client tools]# rpm -qa|grep mysql
[root@nfs_client tools]# yum remove mysql-libs

be careful:
Some systems may be different. Instead of MySQL LIBS, MariaDB LIBS is used. At this time, MariaDB LIBS is to be removed

[root@nfs_client tools]# rpm -qa|grep mariadb
[root@nfs_client tools]# yum remove mariadb-libs

After clearing all mysql dependent packages in yum, you can install mysql components again without reporting an error:
Attention to details:
1> After executing the yum remove MySQL LIBS command, the my.libs in / etc / will be deleted automatically CNF file
2> For installing MySQL components, only mysql-community-server-5.7.22-1.0 is installed el7. x86_ 64.rpm components, only:
a). Generate my.exe under / etc / CNF files and my cnf. D folder

b). Produce the following three folders under / var/lib /

c). Generate mysqld.xml under / var/log / Log file

d). Generate mysqld directory under / var/run /

V. log in and create a MySql password

1 start MySql
After installation, use the command service mysqld start or systemctl start mysqld Service starts the MySQL service. (if the MySQL service cannot be started, restart the system.)

systemctl start mysqld.service   # mysql start 
systemctl status mysqld.service  #View mysql status
systemctl stop mysqld.service   #Close mysql

View mysql process ps -ef|grep mysql
View port netstat -anop|grep 3306

eg:

[root@nfs_client tools]# ps -ef|grep mysql
mysql      4102      1  0 14:29 ?        00:00:01 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
root       4806   1464  0 14:43 pts/0    00:00:00 grep --color=auto mysql
[root@nfs_client tools]# ps -ef|grep mysqld
mysql      4102      1  0 14:29 ?        00:00:01 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
root       4829   1464  0 14:43 pts/0    00:00:00 grep --color=auto mysqld
[root@nfs_client tools]# firewall-cmd --state
not running
[root@nfs_client tools]# netstat -anop|grep 3306
tcp6       0      0 :::3306                 :::*                    LISTEN      4102/mysqld          off (0.00/0/0)
[root@nfs_client tools]#

2 log in to mysql and change the root password
Since MySQL 5 In versions before 7.4, there is no password by default. After logging in, you can enter the database directly and then set the password. Later versions have made some changes to security related operations such as passwords. During installation, a temporary password will be generated in the installation log.

  How can I find this temporary password?

  use:

grep 'temporary password' /var/log/mysqld.log
You can query a log record similar to the following:

[root@nfs_client tools]# grep 'temporary password' /var/log/mysqld.log    # In / var / log / mysqld Search field 'temporary password' in log file
2018-07-18T06:02:23.579753Z 1 [Note] A temporary password is generated for root@localhost: n(jPp4l-C33#

n(jPp4l-C33# is the login password. Use this random password to log in, and then change the password. Use the command:

[root@nfs_client tools]# mysql -uroot -p
 Execute the following command to modify MySql root password

After 5.6, mysql has built-in password enhancement mechanism, and low-intensity passwords will report errors:

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

mysql> alter user root@localhost identified by 'sdbrk';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
             or
mysql> set password for root@localhost=password('sdbrk');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

The solution is as follows:

See: ERROR 1819 (HY000): your password does not satisfy the current policy requirements

Step 1: change the policy and set validate_password_policy=0;

mysql> set global validate_password_policy=0;    # At this time, the new password is valid only if its length is greater than or equal to 8 bits, otherwise an error is reported
 Modify valid password length:
mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)

Regardless of setting validate_password_length=1, or 2, 3, 4. The actual value of the parameter 'effective password length' is 4. After 4, the setting is the actual number.

Step 2: reset password:

mysql> set password for root@localhost=password('9527');
Query OK, 0 rows affected, 1 warning (0.00 sec)

Blog content source: https://blog.csdn.net/wudinaniya/article/details/81094578

Added by redphoenix on Fri, 07 Jan 2022 12:24:41 +0200