linux下 mysql 忘记root用户密码解决办法
一、以系統(tǒng)的root用戶(什么,你的系統(tǒng)的root用戶密碼也忘了。那只好看我另外一篇linux下忘記root用戶的解決辦法了先解決這個(gè)問題)登陸系統(tǒng),進(jìn)入終端
[root@localhost /]#
二、殺掉mysql進(jìn)程
方法1、[root@localhost /]#killall mysqld
方法2、[root@localhost /]#ps -aux //查看所有進(jìn)程,找到mysql進(jìn)程的pid
然后
[root@localhost /]#kill pid //pid是mysql的進(jìn)程號(hào)
三、用--skip-grant-tables參數(shù)啟動(dòng)mysqld
[root@localhost /]#/usr/local/mysql/bin/mysqld_safe --skip-grant-tables&
// 其中/usr..../bin是我的mysql安裝目錄
[root@localhost /]#/usr/local/mysql/bin/mysql //進(jìn)入mysql
mysql> use mysql //切換到mysql database
mysql> UPDATE user SET password=password('123456') WHERE user='root';
//將root密碼該為123456了
四、注意事項(xiàng)
The full command to load MySQL like this is:
mysqld_safe --skip-grant-tables --autoclose
(Editor's Note: Our technical reviewer found that he had to launch the mysqld_safe command
without the '--autoclose' flag, otherwise the daemon never started.)
這是國外網(wǎng)站說的,我沒用autoclosa也成功了
但是我在執(zhí)行/usr/local/mysql/bin/mysqld_safe --skip-grant-tables&即出現(xiàn)錯(cuò)誤提示:
./mysqld_safe
starting mysqld daemon with databases from /usr/local/var
STOPPING server from pid file /usr/local/var/localhost.localdomain.pid
mysqld ended
然后進(jìn)入/usr/local/var/
vi ./localhost.localdomain.err 內(nèi)容如下:
050410 04:02:59 mysqld started
050410 4:03:00 InnoDB:Operating system error number 13 in a file operation.
InnoDB:The error means mysqld does not have the access rights to
InnoDB:the directory.
InnoDB:File name ./ibdata1
InnoDB:File operation call:'create'.
InnoDB:Cannot continue operation.
050410 04:03:00 mysqld ended
懷疑是./var目錄的訪問權(quán)限,故如下操作:
chmod 777 ./var
然后重新執(zhí)行后臺(tái),仍出以上錯(cuò)誤,但在localhost.localdomain.err文件中的錯(cuò)誤信息已改為找不到一個(gè)叫做
help.*的文件了(這個(gè)文件名我記不得了)
這是因?yàn)槲业膍ysql安裝目錄的讀寫權(quán)限是這樣造成的
mysql安裝目錄屬于用戶root,但是群組是mysql的
把群組也改為root即可。
轉(zhuǎn)載于:https://www.cnblogs.com/myphoebe/archive/2011/11/01/2231002.html
總結(jié)
以上是生活随笔為你收集整理的linux下 mysql 忘记root用户密码解决办法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 《黎明杀机》X《生化危机》预告 王阿姨被
- 下一篇: sql server 2005 数据库状