2013-07-01 57 views
0

我有一个MySQL数据库在联网的计算机上运行。过去我没有遇到任何麻烦。然而,突然间(重启和周末),我得到MySQL连接IP从指定的IP地址变化

ERROR 1045 (28000): Access denied for user 'root'@'x.x.x.y'. 

这是因为我想通过连接非常奇怪:

mysql -h x.x.x.x -u root 

出于某种原因,我的IP地址(终几个数字后的最后'。')我试图连接到我输入的变化。

我正在运行Ubuntu 12.10。

编辑:远程连接已启动并且可以ping通。 Mysql在计算机上也能正常工作。

回答

0

-h标志后面输入的IP地址/主机名称是您要连接到的MySQL服务器的IP地址/主机名称。错误消息中的IP地址/主机名是您连接的计算机的IP地址/主机名。可能您对动态分配的IP地址进行了更改,并且您的用户帐户未设置为允许从该帐户进行访问。

+1

这正是问题所在。由于我最初是通过子网上的路由器连接的,所以它比通常情况下更加混乱,但是然后将路由器换出来,仍然可以正常连接。但是,显然我的地址改变了,所以我不认为这个错误是指我自己的IP。谢谢。 – user2502003

3
You will need to reset the password. 

First start the mysql server instance or daemon with the --skip-grant-tables option. (security setting) 

Then Execute these statements. 
# mysql -u root mysql 
mysql> UPDATE user SET Password=PASSWORD('your_new_password') where USER='root'; 
mysql> FLUSH PRIVILEGES; 

Finally, restart the instance/daemon without the --skip-grant-tables option. 

You should be able to connect with your new password. 

# mysql -u root -p 
Enter password: your_new_password`enter code here` 

Hope this helps.