Lightweight Ali cloud server installation mysql5.7

Reprinted to blog: https: //www.cnblogs.com/bigbrotherer/p/7241845.html

 

<My Ali cloud lightweight server, that student machine, the system is centos7>

 

In the default CentOS installed MariaDB, MySQL is the branch, but the need for, or to install MySQL in the system, and after the installation is complete, you can directly overwrite MariaDB.

1 Download and install the MySQL official Yum Repository

[root@localhost ~]# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

  Using the above command directly download the installation of Yum Repository, looks about 25KB, and then you can directly install yum.

[root@localhost ~]# yum -y install mysql57-community-release-el7-10.noarch.rpm

  Then began installing MySQL server.

[root@localhost ~]# yum -y install mysql-community-server

  This step may take some time, it will overwrite mariadb before the installation is complete.

At this point MySQL installation is complete, then some set of MySQL.

2 MySQL database settings

  First start MySQL

[root@localhost ~]# systemctl start  mysqld.service

  View MySQL running, running state is shown:

[root@localhost ~]# systemctl status mysqld.service

  At this time, MySQL has started running, but in order to enter at this time MySQL had to first find out the root user password, you can find the password in the log file with the following command:

[root@localhost ~]# grep "password" /var/log/mysqld.log

  The following command into the database:

[root@localhost ~]# mysql -uroot -p

  Enter the initial password, this time can not do anything, because the default MySQL database to operate after the password must be changed:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';

  There is a problem, when setting a new password if set too simple will complain:

  The reason is because there are norms MySQL password settings, specifically related to the value validate_password_policy:

 

  MySQL complete the initial password rules can be viewed with the following command:

复制代码
复制代码
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name                        | Value |
+--------------------------------------+-------+
| validate_password_check_user_name    | OFF   |
| validate_password_dictionary_file    |       |
| validate_password_length             | 4     |
| validate_password_mixed_case_count   | 1     |
| validate_password_number_count       | 1     |
| validate_password_policy             | LOW   |
| validate_password_special_char_count | 1     |
+--------------------------------------+-------+
7 rows in set (0.01 sec)
复制代码
复制代码

  密码的长度是由validate_password_length决定的,而validate_password_length的计算公式是:

validate_password_length = validate_password_number_count + validate_password_special_char_count + (2 * validate_password_mixed_case_count)

 

我的是已经修改过的,初始情况下第一个的值是ON,validate_password_length是8。可以通过如下命令修改:

mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=1;

  设置之后就是我上面查出来的那几个值了,此时密码就可以设置的很简单,例如1234之类的。到此数据库的密码设置就完成了。

  但此时还有一个问题,就是因为安装了Yum Repository,以后每次yum操作都会自动更新,需要把这个卸载掉:

[root@localhost ~]# yum -y remove mysql57-community-release-el7-10.noarch

  此时才算真的完成了。

Guess you like

Origin www.cnblogs.com/Lovis/p/11263799.html