天天看點

deepin mysql密碼_deepin官方論壇-深度科技官網旗下網站

deepin安裝mysql密碼問題解決方案

1.安裝mysql

更新倉庫:sudo apt-get update

安裝:sudo apt-get install mysql-server mysql-client

問題:安裝mysql5.7的過程中 無root密碼設定提示 直接安裝完成結束

2.不知道密碼狀态下打開mysql

查詢mysql是否運作:sudo netstat -tap |grep mysql

(有顯示就表示已運作)

備注:mysql 打開(service mysql start) 關閉(service mysql stop) 重新開機指令(service mysql restart)

查詢預設的使用者名和密碼:sudo cat /etc/mysql/debian.cnf

[email protected]:~$ sudo cat /etc/mysql/debian.cnf

# Automatically generated for Debian scripts. DO NOT TOUCH!

[client]

host     = localhost

user     = debian-sys-maint

password = F64nKZ233QkzL8v9

socket   = /var/run/mysqld/mysqld.sock

[mysql_upgrade]

host     = localhost

user     = debian-sys-maint

password = F64nKZ233QkzL8v9

socket   = /var/run/mysqld/mysqld.sock

備注:這樣比較麻煩,無法複制密碼,可以直接打開你的檔案管理器,用管理者身份打開debian.cnf即可檢視複制密碼

利用預設賬戶進行登入:mysql -u debian-sys-maint -p(檔案中的密碼,與p之間不要有空格)

3.進入mysql修該密碼

這句必須:update mysql.user set plugin="mysql_native_password" where user="root";

設定root賬戶密碼:update mysql.user set authentication_string=password('這裡是你的密碼') where user='root'and Host = 'localhost';

4.退出資料庫

exit

重新啟動資料庫

sudo service mysql restart

用自己設定好的密碼登入

mysql -u root -p

輸入密碼,成功登入,如下.

[email protected]:~$ mysql -u root -p

Enter password:

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

Your MySQL connection id is 4

Server version: 5.7.21-1 (Debian)

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>

同學 你成功了!