網上直接的update user set password=password("new password") where user='name'; 基本就是坑跌
使用本文方法修改成功!
方法一:
(適用於管理員或者有全域性許可權的使用者重設其它使用者的密碼)
進入命令列模式
mysql -u root mysql
mysql> update user set password=password("new password") where user='name';
mysql> flush privileges;
mysql> quit
方法二:
(應用同上,只是方法不同)
mysql -u root mysql
mysql> set password for name=password('new password');
mysql> quit
(以上兩種方法我不常用,如果是管理員,我會用其它如phpmyadmin或者mysql-front 等工具來管理使用者許可權,比較直觀又方便)
最後必殺技:
mysqladmin -u root "old password" "new password"
解:以上有name的,請用你的使用者名稱來替代.有new password請輸入你想要設定的密碼.
提示錯誤:no database selected後如何修改
c:\mysql\bin>mysql
-uroot
welcome to the mysql monitor. commands end with ; or \g.
your mysql connection id is 4 to server version: 4.0.15-nt
type 'help;' or '\h' for help. type '\c' to clear the buffer.
mysql> update user set password=password('root') where user='root';
error 1046: no database selected
mysql> use mysql
database changed
mysql> select host,user from user;
+-----------+------+
| host | user |
+-----------+------+
| % | |
| % | root |
| localhost | |
| localhost | root |
+-----------+------+
4 rows in set (0.02 sec)
mysql> update user set password=password('root') where user='root';
query ok, 2 rows affected (0.00 sec)
rows matched: 2 changed: 2 warnings: 0
mysql> flush privileges;
query ok, 0 rows affected (0.02 sec)
mysql> quit
byec:\mysql\bin>mysql -uroot
error 1045: access denied for user: 'root@localhost' (using password: no)
c:\mysql\bin>mysql -uroot -proot
welcome to the mysql monitor. commands end with ; or \g.
your mysql connection id is 6 to server version: 4.0.15-nt
type 'help;' or '\h' for help. type '\c' to clear the buffer.
mysql> quit
bye
MySQL修改root密碼
整理了以下四種在mysql中修改root密碼的方法,可能對大家有所幫助 方法1 用set password命令 mysql u root mysql set password for root localhost password newpass 特別注意 此處的password關鍵字是對後面 ne...
mysql修改root密碼
修改mysql初始化密碼 連線mysql mysql u root p123456 enter password設定密碼 set password for root localhost password 123456 刪除mysql密碼校驗 預設不能使用簡單密碼 mysql set global v...
mysql修改root密碼
忘記mysql的root密碼的情況下,重置root密碼!system centos mysql version 5.0 5.5 1.停掉mysql service mysqld stop 2.配置檔案 etc my.cnf中 mysqld 下 新增 skip grant tables 3.啟動mys...