mysql5.7 安裝后無法設(shè)置密碼
問題描述
版本以及操作系統(tǒng):Server version: 5.7.17-0ubuntu0.16.04.1 (Ubuntu-server)
嘗試直接apt-get install mysql-server,安裝過程中彈出讓輸入密碼的框都直接回車。
安裝好之后,輸入mysql可以直接登陸數(shù)據(jù)庫,嘗試用mysqladmin -u root password 'password'``來設(shè)置密碼,彈出兩條警告:
$ mysqladmin -u root password '123'mysqladmin: [Warning] Using a password on the command line interface can be insecure.Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
再次嘗試登陸,還是可以直接輸入mysql登陸(嘗試過重啟數(shù)據(jù)庫)。
第二次嘗試登陸進數(shù)據(jù)庫,使用update mysql.user set authentication_string=PASSWORD(’123123’) where user=’root’;設(shè)置,然后刷新權(quán)限flush privileges;
再次嘗試登陸,還是不用輸任何密碼就可以登陸成功(有重啟數(shù)據(jù)庫)
那么,現(xiàn)在問題來了:
我要怎樣才能成功的給數(shù)據(jù)庫設(shè)個密碼呢?(除了在安裝時彈出框里輸入)
問題解答
回答1:官方文檔這里有提示,你根據(jù)提示看看https://dev.mysql.com/doc/mys...僅對于MySQL 5.7:在服務(wù)器的初始啟動時,出現(xiàn)以下情況,假定服務(wù)器的數(shù)據(jù)目錄為空:服務(wù)器已初始化。SSL證書和密鑰文件在數(shù)據(jù)目錄中生成。該 validate_password插件安裝并啟用。’root’@’localhost’ 創(chuàng)建 超級用戶帳戶。超級用戶的密碼被設(shè)置并存儲在錯誤日志文件中。要顯示它,請使用以下命令:shell> sudo grep ’temporary password’ /var/log/mysqld.log通過使用生成的臨時密碼登錄并為超級用戶帳戶設(shè)置自定義密碼,盡快更改root密碼:shell> mysql -uroot -p mysql> ALTER USER ’root’@’localhost’ IDENTIFIED BY ’MyNewPass4!’;注意默認情況下 安裝MySQL的 validate_password插件。這將要求密碼至少包含一個大寫字母,一個小寫字母,一個數(shù)字和一個特殊字符,并且總密碼長度至少為8個字符。
回答2:試試使用 mysql_secure_installion
回答3:你的賬號里面應(yīng)該是有空賬號 你并沒有刪除或者為這個空賬號設(shè)置密碼delete from mysql.user where user=’’;flush privileges;或者update mysql.user set authentication_string=PASSWORD(’123123’);flush privileges;
相關(guān)文章:
1. docker images顯示的鏡像過多,狗眼被亮瞎了,怎么辦?2. android - 百度地圖加載完成監(jiān)聽3. 關(guān)于docker下的nginx壓力測試4. nignx - docker內(nèi)nginx 80端口被占用5. java - 阿里的開發(fā)手冊中為什么禁用map來作為查詢的接受類?6. macos - mac下docker如何設(shè)置代理7. python3.x - git bash如何運行.bat文件?8. dockerfile - [docker build image失敗- npm install]9. golang - 用IDE看docker源碼時的小問題10. docker api 開發(fā)的端口怎么獲取?
