MySQL连接ip从指定的ip地址更改

时间:2013-07-01 17:27:54

标签: mysql ubuntu ip-address

我在联网计算机上运行MySQL数据库。我过去没遇到任何麻烦。然而,突然之间(重启和周末之后),我得到了

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在计算机上也能正常运行。

2 个答案:

答案 0 :(得分: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. 

答案 1 :(得分:0)

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

相关问题