這個MySQL有點怪啊,突然間用原賬號就登陸不上了(具體原因不詳,有知道的告訴我);所以決定修改下原密碼。
1.停掉MySQL,然后用無權(quán)限驗證的方式重新啟動MySQL 命令:
Linux下,運行 /usr/local/mysql/bin/mysqld_safe --skip-grant-tables &
Windows下,在命令行下運行 X:/MySQL/bin/mysqld --skip-grant-tables
2.在命令行下用,mysql -u -root登陸
3.修改下密碼吧,一位博主(http://blog.chinaunix.net/u/29134/showart_373855.html)寫的方法比較全,我就不羅嗦了。三種方法任何一個都行
新手在這個上往往容易范錯誤,導(dǎo)致不能進入MYSQL,整得非常郁悶。
我來做幾個例子相信很快就明白了 。
1、原來的密碼是123456
C:\>type mysql5.bat
@echo off
mysql -uroot -p123456 -P3306
正確的修改MYSQL用戶密碼的格式是:
我們這里用
用戶:root(可以換成其他的)
密碼:woshiduide
來演示新密碼。
C:\>mysqladmin -uroot -p password woshiduide
Enter password: ******
于是修改成功。
注意PASSWORD關(guān)鍵字后面的空格
有好多人是這樣修改的:
C:\>mysqladmin -uroot -p password 'woshiduide'
Enter password: ******
C:\>mysqladmin -uroot -p password 'woshiduide'
Enter password: *********
Warning: single quotes were not trimmed from the password by your command
line client, as you might have expected.
而這個時候真正的密碼是'woshiduide'
C:\>mysql -uroot -p'woshiduide'
Welcome to the MySQL monitor.? Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 5.1.17-beta-community-nt-debug MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
而新手往往這樣:
C:\>mysql -uroot -pwoshiduide
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: Y
ES)
所以非常郁悶,BAIDU、GOOGLE的搜了一大堆。
我現(xiàn)在把密碼改回去。
C:\>mysqladmin -uroot -p'woshiduide' password 123456
2、還有就是可以直接進入MYSQL,然后修改密碼。
mysql> use mysql
Database changed
mysql> update user set PASSWORD = PASSWORD('woshiduide') where USER='root' and H
OST='localhost';
Query OK, 1 row affected (0.05 sec)
Rows matched: 1? Changed: 1? Warnings: 0
mysql> flush privileges;
mysql> exit
Bye
C:\>mysql -uroot -pwoshiduide
Welcome to the MySQL monitor.? Commands end with ; or \g.
Your MySQL connection id is 23
Server version: 5.1.17-beta-community-nt-debug MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
Query OK, 0 rows affected (0.02 sec)
3、還有一種就是用SET PASSWORD 命令修改:
C:\>mysql5.bat
Enter password: ******
Welcome to the MySQL monitor.? Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.1.17-beta-community-nt-debug-log MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> set password for root@'localhost' = password('woshiduide');
Query OK, 0 rows affected (0.02 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.09 sec)
mysql> exit
Bye
4、GRANT 也可以,不過這里不介紹。因為涉及到權(quán)限的問題。
1.停掉MySQL,然后用無權(quán)限驗證的方式重新啟動MySQL 命令:
Linux下,運行 /usr/local/mysql/bin/mysqld_safe --skip-grant-tables &
Windows下,在命令行下運行 X:/MySQL/bin/mysqld --skip-grant-tables
2.在命令行下用,mysql -u -root登陸
3.修改下密碼吧,一位博主(http://blog.chinaunix.net/u/29134/showart_373855.html)寫的方法比較全,我就不羅嗦了。三種方法任何一個都行
新手在這個上往往容易范錯誤,導(dǎo)致不能進入MYSQL,整得非常郁悶。
我來做幾個例子相信很快就明白了 。
1、原來的密碼是123456
C:\>type mysql5.bat
@echo off
mysql -uroot -p123456 -P3306
正確的修改MYSQL用戶密碼的格式是:
我們這里用
用戶:root(可以換成其他的)
密碼:woshiduide
來演示新密碼。
C:\>mysqladmin -uroot -p password woshiduide
Enter password: ******
于是修改成功。
注意PASSWORD關(guān)鍵字后面的空格
有好多人是這樣修改的:
C:\>mysqladmin -uroot -p password 'woshiduide'
Enter password: ******
C:\>mysqladmin -uroot -p password 'woshiduide'
Enter password: *********
Warning: single quotes were not trimmed from the password by your command
line client, as you might have expected.
而這個時候真正的密碼是'woshiduide'
C:\>mysql -uroot -p'woshiduide'
Welcome to the MySQL monitor.? Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 5.1.17-beta-community-nt-debug MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
而新手往往這樣:
C:\>mysql -uroot -pwoshiduide
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: Y
ES)
所以非常郁悶,BAIDU、GOOGLE的搜了一大堆。
我現(xiàn)在把密碼改回去。
C:\>mysqladmin -uroot -p'woshiduide' password 123456
2、還有就是可以直接進入MYSQL,然后修改密碼。
mysql> use mysql
Database changed
mysql> update user set PASSWORD = PASSWORD('woshiduide') where USER='root' and H
OST='localhost';
Query OK, 1 row affected (0.05 sec)
Rows matched: 1? Changed: 1? Warnings: 0
mysql> flush privileges;
mysql> exit
Bye
C:\>mysql -uroot -pwoshiduide
Welcome to the MySQL monitor.? Commands end with ; or \g.
Your MySQL connection id is 23
Server version: 5.1.17-beta-community-nt-debug MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
Query OK, 0 rows affected (0.02 sec)
3、還有一種就是用SET PASSWORD 命令修改:
C:\>mysql5.bat
Enter password: ******
Welcome to the MySQL monitor.? Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.1.17-beta-community-nt-debug-log MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> set password for root@'localhost' = password('woshiduide');
Query OK, 0 rows affected (0.02 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.09 sec)
mysql> exit
Bye
4、GRANT 也可以,不過這里不介紹。因為涉及到權(quán)限的問題。