亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

文字

CentOS7 安裝 Mysql 5.7密碼查看與修改

軟件版本

CentOS release 6.9 (Final)
mysql Client Ver 14.14 Distrib 5.7.18, for Linux (x86_64) using  EditLine wrapper
mysql Server 5.7.18

檢測是否安裝MySQLServer

檢測下系統(tǒng)有沒有自帶的mysql:yum list installed | grep mysql

如果已經(jīng)有的話執(zhí)行命令 yum -y remove mysql-libs.x86_64 卸載已經(jīng)安裝的 MySQL 。

安裝

使用 rpm 包進行mysql服務器的安裝,具體下載地址在:https://dev.mysql.com/downloads/mysql/5.7.html#downloads

wget http://repo.mysql.com/yum/mysql-5.7-community/el/6/x86_64/mysql-community-server-5.7.18-1.el6.x86_64.rpm
rpm -ivh mysql-community-server-5.7.18-1.el6.x86_64.rpm

啟動

service mysqld start

查看密碼

安裝完成之后會自動在 /var/log/mysqld.log 中生成連接的密碼, 使用 grep "temporary password" /var/log/mysqld.log 命令查看生成的密碼。

初次登錄MySQL客戶端必須重新設置密碼才能進行數(shù)據(jù)的操作,如下:

[root@localhost src]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.18
Copyright (c) 2000, 2017, 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> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

密碼設置

不過需要注意的是現(xiàn)在MySQL已經(jīng)強制要求強密碼,已經(jīng)不能再用弱密碼比如“123456”了。如果你設置的密碼過于簡單,會提示錯誤:

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

set password 命令

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');

mysqladmin 命令

mysqladmin -u root password "newpass" # 如果root沒有設置密碼使用這種方式
mysqladmin -u root password oldpass "newpass" # 如果root設置了密碼使用這種方式

使用 update 語句

UPDATE user SET authentication_string = PASSWORD('newpass') WHERE user = 'root';

忘記密碼

mysqld_safe --skip-grant-tables&
mysql -u root mysql
mysql> UPDATE user SET authentication_string=PASSWORD("new password") WHERE user='root';
mysql> FLUSH PRIVILEGES;

密碼復雜度的修改

mysql> show variables like "validate_password%";
+--------------------------------------+--------+
| Variable_name                        | Value  |
+--------------------------------------+--------+
| validate_password_check_user_name    | OFF    |
| validate_password_dictionary_file    |        |
| validate_password_length             | 8      | # 必須8個字符以上
| validate_password_mixed_case_count   | 1      |
| validate_password_number_count       | 1      |
| validate_password_policy             | MEDIUM | # 具體看下面的配置
| validate_password_special_char_count | 1      |
+--------------------------------------+--------+
7 rows in set (0.01 sec)
mysql> SET GLOBAL  validate_password_policy='LOW';
Query OK, 0 rows affected (0.00 sec)
mysql> SET GLOBAL validate_password_length = 6;
Query OK, 0 rows affected (0.00 sec)
  • LOW政策只測試密碼長度。 密碼必須至少有8個字符長。

  • MEDIUM政策的條件 密碼必須包含至少1數(shù)字字符,1 大寫和小寫字符,和1特別 (nonalphanumeric)字符。

  • STRONG政策的情況 密碼子字符串長度為4的或更長時間不能匹配 單詞在字典文件中,如果一個人被指定。

再進行密碼的修改試試。

創(chuàng)建用戶并授權(quán)

CREATE USER 'test'@'%' IDENTIFIED BY 'password';
GRANT ALL ON test.* TO 'test'@'%' WITH GRANT OPTION;


上一篇: 下一篇: