Windows下安装MySql后,使用客户端连接

报:

error: 'Access denied for user 'root'@'localhost' (using password: YES)'

 

解决办法:

首先在my.ini中的[mysqld]的段中加上一句skip-grant-tables

跳过权限检查。

其次,在命令行模式或者图形模式下更新mysql库的user表的数据。

Update user set password=password(123456) where user=root

你要确保语句执行成功。

 

解决原因:

MySQL安装之后就无法访问让人郁闷,主要是因为之前安装过,Data文件没删除。导致再次安装后,发现user表中的password字段为空。只要把密码赋值就可以解决了。

 

"Host 'localhost' is not allowed to connect to this MySQL server

解决办法:

在命令行模式或者图形模式下更新mysql库的user表的数据。

保证存在host=localhost的记录。

 

最后你可以用php测试下

简单的PHP连接MySQL数据库的代码

<?php  

$link=mysql_connect("localhost","root","password"); 

if (!$link) echo "connect error";  

else echo "connect ok";  

?>