Install mysql database and problem solving

1, mysql official website to download the installation package, the official website address: www.mysql.com

[root@seiang software]# ll

total 580020

-rw-r--r--. 1 root root 593940480 Mar 25 18:57 mysql-5.7.21-1.el7.x86_64.rpm-bundle.tar

 

2, extract

[root@seiang software]# tar xvf mysql-5.7.21-1.el7.x86_64.rpm-bundle.tar

mysql-community-embedded-devel-5.7.21-1.el7.x86_64.rpm

mysql-community-minimal-debuginfo-5.7.21-1.el7.x86_64.rpm

mysql-community-common-5.7.21-1.el7.x86_64.rpm

mysql-community-libs-compat-5.7.21-1.el7.x86_64.rpm

mysql-community-embedded-compat-5.7.21-1.el7.x86_64.rpm

mysql-community-server-minimal-5.7.21-1.el7.x86_64.rpm

mysql-community-client-5.7.21-1.el7.x86_64.rpm

mysql-community-server-5.7.21-1.el7.x86_64.rpm

mysql-community-embedded-5.7.21-1.el7.x86_64.rpm

mysql-community-test-5.7.21-1.el7.x86_64.rpm

mysql-community-devel-5.7.21-1.el7.x86_64.rpm

mysql-community-libs-5.7.21-1.el7.x86_64.rpm

 

3, the entire installation, the following error occurs

[root@seiang software]# rpm -ivh *.rpm

warning: mysql-community-client-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

error: Failed dependencies:

        mariadb-libs is obsoleted by mysql-community-libs-5.7.21-1.el7.x86_64

        mariadb-libs is obsoleted by mysql-community-libs-compat-5.7.21-1.el7.x86_64

        perl(Data::Dumper) is needed by mysql-community-test-5.7.21-1.el7.x86_64

        perl(JSON) is needed by mysql-community-test-5.7.21-1.el7.x86_64

 

4, as the error due to centos 7 mariadb default database, go to first before installing mysql download mariadb

[root@seiang software]# rpm -qa | grep mariadb

mariadb-libs-5.5.41-2.el7_0.x86_64

 

[root@seiang software]# rpm -e mariadb-libs-5.5.41-2.el7_0.x86_64

error: Failed dependencies:

        libmysqlclient.so.18()(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64

        libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64

 

Because of the dependency, forced uninstall

[root@seiang software]# rpm -e --nodeps mariadb-libs-5.5.41-2.el7_0.x86_64

 

5, the installation mysql-server, an error occurs

[root@seiang software]# rpm -ivh mysql-community-server-5.7.21-1.el7.x86_64.rpm

warning: mysql-community-server-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

error: Failed dependencies:

        mysql-community-client(x86-64) >= 5.7.9 is needed by mysql-community-server-5.7.21-1.el7.x86_64

        mysql-community-common(x86-64) = 5.7.21-1.el7 is needed by mysql-community-server-5.7.21-1.el7.x86_64

 

6, the prompts, the first installation mysql-community-common and mysql-community-client packet

[root@seiang software]# rpm -ivh mysql-community-common-5.7.21-1.el7.x86_64.rpm

warning: mysql-community-common-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

   1:mysql-community-common-5.7.21-1.e################################# [100%]

 

 7, the installation package mysql-client, the following error occurs

[root@seiang software]# rpm -ivh mysql-community-client-5.7.21-1.el7.x86_64.rpm

warning: mysql-community-client-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

error: Failed dependencies:

        mysql-community-libs(x86-64) >= 5.7.9 is needed by mysql-community-client-5.7.21-1.el7.x86_64

 

8, prompted to install package mysql-community-libs

[root@seiang software]# rpm -ivh mysql-community-libs-5.7.21-1.el7.x86_64.rpm

warning: mysql-community-libs-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

   1:mysql-community-libs-5.7.21-1.el7################################# [100%]

 

9, try again to install mysql-client

[root@seiang software]# rpm -ivh mysql-community-client-5.7.21-1.el7.x86_64.rpm

warning: mysql-community-client-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

   1:mysql-community-client-5.7.21-1.e################################# [100%]

 

10, the final installation mysql-server

[root@seiang software]# rpm -ivh mysql-community-server-5.7.21-1.el7.x86_64.rpm

warning: mysql-community-server-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

   1:mysql-community-server-5.7.21-1.e################################# [100%]

 

11, see the mysql service

[root@seiang software]# systemctl status mysqld.service

mysqld.service - MySQL Server

   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)

   Active: inactive (dead)

     Docs: man:mysqld(8)

           http://dev.mysql.com/doc/refman/en/using-systemd.html

 

12, start mysql service

[root@seiang software]# systemctl start mysqld.service

[root@seiang software]#

[root@seiang software]# systemctl status mysqld.service

mysqld.service - MySQL Server

   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)

   Active: active (running) since Mon 2018-03-26 09:26:04 CST; 2s ago

     Docs: man:mysqld(8)

           http://dev.mysql.com/doc/refman/en/using-systemd.html

  Process: 2113 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)

  Process: 2034 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)

 Main PID: 2116 (mysqld)

   CGroup: /system.slice/mysqld.service

           鈹斺攢2116 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

 

Mar 26 09:25:54 seiang systemd[1]: Starting MySQL Server...

Mar 26 09:26:04 seiang systemd[1]: Started MySQL Server.

 

13, mysql service starts successfully, the first to use a temporary password to log in to view the temporary password

[root@seiang software]#  grep "password" /var/log/mysqld.log

2018-03-25T11:18:09.770923Z 1 [Note] A temporary password is generated for root@localhost: &)2KIh?M3hr7

2018-03-25T11:19:39.853663Z 2 [Note] Access denied for user 'root'@'localhost' (using password: YES)

2018-03-25T11:22:20.996230Z 3 [Note] Access denied for user 'root'@'localhost' (using password: NO)

2018-03-25T11:24:31.219087Z 0 [Note] Shutting down plugin 'validate_password'

2018-03-25T11:24:33.062278Z 0 [Note] Shutting down plugin 'sha256_password'

2018-03-25T11:24:33.062286Z 0 [Note] Shutting down plugin 'mysql_native_password'

2018-03-26T01:25:57.938742Z 1 [Note] A temporary password is generated for root@localhost: v,esvf2?oj?T

 

14, using a temporary password, and then modify the root password

[root@seiang software]# mysql -uroot -pv,esvf2?oj?T

mysql: [Warning] Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.7.21

 

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

 

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

mysql>

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'beijing';

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

 

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'qcloud@2018';

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

 

Two modifications are suggesting the same error: ERROR 1819 (HY000): Your password does not Satisfy requirements at The Current Policy

 

Here is the official document, the explanation for the problem:

https://dev.mysql.com/doc/refman/5.7/en/validate-password.html

 

The reason for the above error: in fact related to the value of validate_password_policy.

validate_password_policy have the following values:

 

The default is 1, that is, MEDIUM, so just start setting password must meet the length and must contain numbers, uppercase or lowercase letters, special characters.

 

Solution:

Modify the value of the parameter validate_password_policy

mysql> set global validate_password_policy=0;

Query OK, 0 rows affected (0.00 sec)

 

mysql> select @@validate_password_length;

+----------------------------+

| @@validate_password_length |

+----------------------------+

|                 8 |

+----------------------------+

1 row in set (0.05 sec)

 

The default password length is 8, there will still be less than 8 error 

mysql>  ALTER USER 'root'@'localhost' IDENTIFIED BY 'beijing';

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

Successfully modified 

mysql>  ALTER USER 'root'@'localhost' IDENTIFIED BY 'qcloud@2018';

Query OK, 0 rows affected (0.00 sec)

 

15, again using the new password, the login is successful

[root@seiang software]# mysql -uroot -pqcloud@2018

mysql: [Warning] Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 4

Server version: 5.7.21 MySQL Community Server (GPL)

 

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

 

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

mysql>

 

 

16, because the tips are accustomed to Linux, so we set the prompt to mysql

(1) Temporary settings

mysql> prompt \u@ \h \d >

root@ localhost (none) >

root@ localhost (none) >use mysql;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

 

Database changed

root@ localhost mysql >prompt \u@\h [\d]>

PROMPT set to '\u@\h [\d]>'

root@localhost [mysql]>

root@localhost [mysql]>

 

(2) Permanent set

[root@seiang ~]# vim /etc/my.cnf

Add the following two, Note: [] is mysql, not mysqld

[mysql]

prompt=\u@\h [\d]>

 

Guess you like

Origin www.cnblogs.com/zhoading/p/11538329.html