我的mysql是6.0版的,操作系统是WinXP,在控制台里登陆mysql,发现只用用户名可以登陆,不用输密码,进去后操作正常,但是如果用用户名+密码的方式登陆就出错(用户是我用root账户建的,是有密码的,root账户用密码同样登陆不了,所有登陆均在本地进行),下面是Windows控制台里的提示信息,用户名为zwdnet,密码我确定没输错。麻烦大家帮忙看看,是还要怎么设置吗?谢谢!C:\Documents and Settings\Administrator>mysql -u zwdnet -p
Enter password: **********
ERROR 1045 (28000): Access denied for user 'zwdnet'@'localhost' (using password:
YES)C:\Documents and Settings\Administrator>mysql -u zwdnet
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 6.0.10-alpha-community MySQL Community Server (GPL)Type 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql>
Enter password: **********
ERROR 1045 (28000): Access denied for user 'zwdnet'@'localhost' (using password:
YES)C:\Documents and Settings\Administrator>mysql -u zwdnet
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 6.0.10-alpha-community MySQL Community Server (GPL)Type 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql>
登录进去后
set password=password('password');
退出,用新密码登录。
[code]
mysql> set password = password('123456');
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
mysql> quit
Bye
[/code]
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
mysql> quit
Bye
ByeC:\Documents and Settings\Administrator>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 6.0.10-alpha-community MySQL Community Server (GPL)Type 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> select user,host,password from mysql.user;
+--------+-----------+------------+
| user | host | password |
+--------+-----------+------------+
| root | localhost | |
| root | 127.0.0.1 | |
| | localhost | |
| zwdnet | localhost | (****)这是密码,我略了 |
+--------+-----------+------------+
4 rows in set (0.63 sec)mysql>
| root | 127.0.0.1 | |
| | localhost | |
这几个账号的密码为空贴一下
select current_user();
show grants;检查一下你当前的身份是什么?
+----------------+
| current_user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.09 sec)mysql> show grants;
+---------------------------------------------------------------------+
| Grants for root@localhost |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+
1 row in set (0.01 sec)mysql>
mysql> set password for 'zwdnet'@'localhost' = password('456');
ERROR 1133 (42000): Can't find any matching row in the user table
mysql> set password for 'zwdnet@localhost' = password('456');
ERROR 1133 (42000): Can't find any matching row in the user table
mysql>
+--------+--------------+-----------+--------------+
| user | length(user) | host | length(host) |
+--------+--------------+-----------+--------------+
| root | 4 | 127.0.0.1 | 9 |
| | 0 | localhost | 9 |
| root | 4 | localhost | 9 |
| zwdnet | 6 | localhost | 9 |
+--------+--------------+-----------+--------------+
4 rows in set (0.14 sec)mysql>
mysql>update user set password=password('123456') where user='zwdnet';
mysql>flush privileges;
最好把匿名用户也删除了
mysql>delete from user where user='';
from mysql.user
where user='zwdnet' and host='localhost';
C:\Documents and Settings\Administrator>mysql -u zwdnet
ERROR 1045 (28000): Access denied for user 'zwdnet'@'localhost' (using password:
NO)C:\Documents and Settings\Administrator>mysql -u zwdnet -p
Enter password: **********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 6.0.10-alpha-community MySQL Community Server (GPL)Type 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| test |
+--------------------+
2 rows in set (0.00 sec)mysql>
C:\Documents and Settings\Administrator>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 6.0.10-alpha-community MySQL Community Server (GPL)Type 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> select user,host from mysql.user where user = 'zwdnet' and host = 'localh
ost';;
+--------+-----------+
| user | host |
+--------+-----------+
| zwdnet | localhost |
+--------+-----------+
1 row in set (0.08 sec)ERROR: No query specifiedmysql>