**1.停止MYSQL服務(wù);
在Ubuntu 或 Debian上
sudo service mysql stop
或者
sudo /etc/init.d/mysql stop
在CentOS, Fedora, RHEL上:
sudo service mysqld stop
或者
sudo /etc/init.d/mysqld stop
2.進(jìn)入安全模式
sudo mysqld_safe --skip-grant-tables &
PS:最后的&符號是要有的
你可能會看到這樣的信息:
mysqld_safe Can"t log to error log and syslog at the same time. Remove all --log-error configuration options for --syslog to take effect.
mysqld_safe Logging to "/var/log/mysql/error.log".
mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
出現(xiàn)這些類似信息之后,你可以按CTRL+C退出,然后進(jìn)行下一步
NOTES:如果,我是說如果,沒有報(bào)錯(cuò)請直接跳到第三步,在這你遇到報(bào)錯(cuò)
mysqld_safe Can"t log to error log and syslog at the same time. Remove all --log-error configuration options for --syslog to take effect.
mysqld_safe Logging to "/var/log/mysql/error.log".
mysqld_safe A mysqld process already exists
請使用以下命令來確認(rèn)mysql是否真的終止了
ps uaxww | grep -i mysql
一旦找到,就用kill將進(jìn)程終止,再重試一次
3.使用空密碼登錄
mysql -u root
4.使用mysql數(shù)據(jù)庫
use mysql;
你會看到這樣的類似信息:
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
Database changed
5.重新設(shè)置密碼
update user set password=PASSWORD("yournewpassword") where User="root";
yournewpassword 替換為你設(shè)置的密碼
你大概會看到這些:
mysql> update user set password=PASSWORD("yournewpassword") where User="root";
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0
flush privileges;
如果出現(xiàn)以下熟悉的提示,基本上大功告成。
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
7.退出
quit
在Ubuntu 或 Debian上
sudo /etc/init.d/mysql stop
然后
sudo /etc/init.d/mysql start
在CentOS, Fedora, RHEL上:
sudo /etc/init.d/mysqld stop
然后
sudo /etc/init.d/mysqld start
mysql -u root -p
輸入剛剛設(shè)置的密碼。DONE**
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請注明本文地址:http://specialneedsforspecialkids.com/yun/23036.html
閱讀 3629·2021-11-23 09:51
閱讀 1512·2021-11-04 16:08
閱讀 3568·2021-09-02 09:54
閱讀 3636·2019-08-30 15:55
閱讀 2620·2019-08-30 15:54
閱讀 978·2019-08-29 16:30
閱讀 2067·2019-08-29 16:15
閱讀 2340·2019-08-29 14:05