0

无法使用 mysql 工作台或直接命令行连接到远程 mysql 服务器。尝试时解析不同的主机名

Mysql工作台报错信息

直接通过命令行尝试时

mysql --host=10.37.1.92 --port=3306 --user=root --password=password
Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'myaapvm.local' (using password: YES)

试过了,有密码和没有密码,没有运气。

我尝试连接到 10.37.1.92 服务器,但我的 mysql 客户端尝试连接到不同的服务器。我现在可以尝试的唯一方法是直接登录机器并在我的数据库中进行更改。我在我的 mysql 数据库中禁用了防火墙。有没有人遇到过这个问题请帮忙。

此服务器运行 maria DB 安装。

4

1 回答 1

3

默认情况下,不允许 root 使用远程连接访问数据库。我建议您创建一个用于远程连接的新用户。您可以使用以下 SQL 命令来执行此操作:

    CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypass';
    CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypass';

    GRANT ALL ON *.* TO 'myuser'@'localhost';
    GRANT ALL ON *.* TO 'myuser'@'%';
    FLUSH PRIVILEGES;

如果您还没有这样做,您还需要修改 my.cnf。

    #Replace xxx with your IP Address 
    bind-address        = xxx.xxx.xxx.xxx
于 2020-01-24T08:01:50.923 回答