標籤:
在digitialOcean購買的主機用了一段時間,感覺還行。最近在幫朋友的撞球室做開發,使用了ucToo這個開發架構,在安裝的時候,發現主機上的mysql連結有問題,使用navicat串連也是連不上,於是用xshell進行操作,mysql的帳號還是有問題,可能是當時安裝環境的時候忘記所設定的mysql的使用者名稱和密碼,在網上尋找了之後,發現了一個好用的辦法:
2.修改MySQL的登入設定: # vi /etc/my.cnf 在[mysqld]的段中加上一句:skip-grant-tables 例如: [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock skip-name-resolve skip-grant-tables 儲存並且退出vi。
3.重新啟動mysqld # /etc/init.d/mysqld restart Stopping MySQL: [ OK ] Starting MySQL: [ OK ]
4.登入並修改MySQL的root密碼 # /usr/bin/mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 to server version: 3.23.56 Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer. mysql> USE mysql ; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A
atabase changed mysql> UPDATE user SET Password = password ( ‘new-password’ ) WHERE User = ‘root’ ; Query OK, 0 rows affected (0.00 sec) Rows matched: 2 Changed: 0 Warnings: 0 mysql> flush privileges ; Query OK, 0 rows affected (0.01 sec) mysql> quit Bye
5.將MySQL的登入設定修改回來 # vi /etc/my.cnf 將剛才在[mysqld]的段中加上的skip-grant-tables刪除 儲存並且退出vi。
6.重新啟動mysqld # /etc/init.d/mysqld restart Stopping MySQL: [ OK ] Starting MySQL: [ OK ]
資料來源【http://wenku.baidu.com/link?url=8qX5znAwZNrTFXCHcp9qhOo-Gn5SmjDVdV_wmC6NYLL0-0Ewud6AYOT9niOc-A2P8eUOucl8lC-PtKnbhhQR905lIvi6OSppyqRJm5eJBAC 】
mysql忘記密碼怎麼辦?