Mysql-安裝指南
出現這個問題的原因是:密碼過於簡單。剛安裝的mysql的密碼默認強度是最高的,如果想要設置簡單的密碼就要修改validate_password_policy的值,
validate_password_policy有以下取值:
Policy | Tests Performed |
---|---|
0 or LOW |
Length |
1 or MEDIUM |
Length; numeric, lowercase/uppercase, and special characters |
2 or STRONG |
Length; numeric, lowercase/uppercase, and special characters; dictionary file |
默認是1,因此我們就設置中增加大小寫和特殊字符即可。
2、配置允許外網連接
2.登錄數據庫
mysql -u root -p
#輸入密碼
3.轉到系統數據庫
mysql> use mysql;
4.查詢host
mysql> select user,host from user;
5.創建host
#如果沒有"%"這個host值,就執行下面這兩句:
mysql> update user set host=‘%‘ where user=‘root‘;
mysql> flush privileges;
6.授權用戶
#任意主機以用戶root和密碼mypwd連接到mysql服務器
mysql> grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘mypwd‘ with grant option;
#IP為192.168.1.100的主機以用戶myuser和密碼mypwd連接到mysql服務器
mysql> grant all privileges on *.* to ‘myuser‘@‘192.168.1.100‘ identified by ‘mypwd‘ with grant option;
7.刷新權限
mysql> flush privileges;
操作截圖如下:
忘記密碼參考:
CentOS7 通過YUM安裝MySQL5.7
參考:
1 設置MySQL允許外網訪問
2 CentOS7 通過YUM安裝MySQL5.7
Mysql-安裝指南