简体   繁体   English

MySQL - ODBC 连接失败,Workbench 连接有效

[英]MySQL - ODBC connect fails, Workbench connect works

I am trying to install and test a MySQL ODBC Connector on my machine (Windows 7) to connect to a remote MySQL DB server, but, when I configure and test the connection, I keep getting the following error:我正在尝试在我的机器 (Windows 7) 上安装和测试 MySQL ODBC 连接器以连接到远程 MySQL 数据库服务器,但是,当我配置和测试连接时,我不断收到以下错误:

Connection Failed
[MySQL][ODBC 5.3(w) Driver]Access denied for user 'root'@'(my host)' (using password: YES):

The problem is, I can connect with MySQL Workbench (remotely - from my local machine to the remote server) just fine.问题是,我可以很好地连接 MySQL Workbench(远程 - 从我的本地机器到远程服务器)。 I have read this FAQ extensively but it's not helping out.我已经广泛阅读了这个常见问题,但它没有帮助。 I have tried:我试过了:

  • Checking if mysql is running on the server (it is. I even tried restarting it many times);检查 mysql 是否在服务器上运行(确实如此。我什至尝试过多次重新启动它);
  • Checking if the port is listening for connection on the remote server.检查端口是否正在侦听远程服务器上的连接。 It is.这是。
  • Connecting to the remote server using MySQL Workbench.使用 MySQL Workbench 连接到远程服务器。 It works.有用。
  • Checking if the IP address and Ports of the remote database are correct;检查远程数据库的IP地址和端口是否正确;
  • Checking if the user (root) and password are correct;检查用户(root)和密码是否正确;
  • Re-entering the password on the ODBC config window;在 ODBC 配置窗口中重新输入密码;
  • Checking and modifying the contents of the "my.conf" on the remote server to allow connections from all sides (0.0.0.0);检查和修改远程服务器上“my.conf”的内容以允许来自各方的连接(0.0.0.0);
  • Including (my host) on the GRANT HOST tables from mySQL (I also tried the wildcard '%' but it's the same as nothing);在来自 mySQL 的 GRANT HOST 表中包含(我的主机)(我也尝试了通配符 '%',但它与没有相同);
  • Running a FLUSH HOSTS;运行 FLUSH HOSTS; And FLUSH PRIVILEGES;和冲洗特权; command on the remote mySQL server to reset the privilege cache;远程mySQL服务器上的命令重置权限缓存;
  • Turning off my Firewall during the configuration of the ODBC driver;在配置 ODBC 驱动程序期间关闭我的防火墙;
  • Checked if the MySQL variable 'skip_networking' is OFF in order to allow remote connections.检查 MySQL 变量“skip_networking”是否关闭以允许远程连接。

What is frustrating is that I can connect with MySQL Workbench on my local machine (with the same IP/user/password), just not with ODBC.令人沮丧的是,我可以在我的本地机器上连接 MySQL Workbench(使用相同的 IP/用户/密码),只是不能使用 ODBC。

What could I be doing wrong, or what could be messing up my attempt to connect with ODBC?我可能做错了什么,或者什么可能会破坏我与 ODBC 连接的尝试?

Update : I managed to set up the ODBC driver and get it running correctly on the server side.更新:我设法设置了 ODBC 驱动程序并让它在服务器端正确运行。 I can connect there to the localhost using a command line (with the "isql" command).我可以使用命令行(使用“isql”命令)连接到本地主机。 But I still can't connect over remotely with my Windows 7 machine.但是我仍然无法通过我的 Windows 7 机器远程连接。

Solved.解决了。

As it turns out, it was a permissions problem.事实证明,这是一个权限问题。 I ran the following command on the remote server SQL:我在远程服务器 SQL 上运行了以下命令:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'(my_host)' IDENTIFIED BY '(my_password)';

I had run the previous command, but without the "IDENTIFIED BY" password.我已经运行了上一个命令,但没有“IDENTIFIED BY”密码。 Then, to reset the mysql permissions cache, I also ran然后,为了重置 mysql 权限缓存,我也跑了

FLUSH PRIVILEGES;

And now it works.现在它起作用了。

也只适用于 64 位 odbc 驱动程序而不适用于 mySQL 32 位。

We had a similar case that 'user'@'%' was granted at server but ODBC connect failed at a PC while workbench connect successfully.我们有一个类似的情况,即在服务器上授予了 'user'@'%' 权限,但 ODBC 连接在 PC 上失败,而工作台连接成功。

MariaDB 10.0.31, MySQL ODBC 3.51, MySQL Workbench 8.0 MariaDB 10.0.31、MySQL ODBC 3.51、MySQL 工作台 8.0

Solved by install MariaDB Connector/ODBC 3.1 instead of the MySQL ODBC ( https://downloads.mariadb.org/connector-odbc/ ).通过安装 MariaDB Connector/ODBC 3.1 而不是 MySQL ODBC ( https://downloads.mariadb.org/connector-odbc/ ) 解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM