I am using Delphi 10.4 Community addition, and Zeos 7.2.14. Have written a simple app which I can connect to a MySQL on my same development computer. But when I run this app from another computer with valid hostName = IP address of the dev computer, I get a "SQL Error: Access denied for user 'root'@'2ndComputerName' (using password: Yes). Password is set correctly in ZConnection - as I can access the db from dev machine running same app. I know the Community addition has limits on Client/Server. I was hoping using Zeos would work.
Incidentally, when I connect the app running on my dev machine to HostName = IP address of same computer (192.168.2.15) I get the same error. I know, localhost or 127.0.0.1 do work. And yes, Dev machine is on a static IP address.
I have another app developed in C# which accesses same MySQL server on dev machine which i can access from 2nd computer, and it runs fine. So I know my MySQL server and the credentials are working properly. I just would rather develop in Delphi! Also, I can point this C# app on dev computer to its own IP address (192.168.2.15) and that works. Anyone have thoughts as to what may be causing the error?
Thanks much!
Doug
Can't connect to MySQL server on LAN
Re: Can't connect to MySQL server on LAN
Hi Doug,
Show what you have for ZConnection in .dfm and what MySQL and client version you are using
Michał
Show what you have for ZConnection in .dfm and what MySQL and client version you are using
Michał
-
- Platinum Boarder
- Posts: 1956
- Joined: 17.01.2011, 14:17
Re: Can't connect to MySQL server on LAN
Basically this is a MySQL error. Please read their documentation about users. I seem to remember that you need a user like "root@%". On my MariaDB server I do have a user called "root@192.168.1.0/255.255.255.0" that allows me to access MariaDB from our local network.svtdoug wrote: ↑15.11.2021, 01:38 I am using Delphi 10.4 Community addition, and Zeos 7.2.14. Have written a simple app which I can connect to a MySQL on my same development computer. But when I run this app from another computer with valid hostName = IP address of the dev computer, I get a "SQL Error: Access denied for user 'root'@'2ndComputerName' (using password: Yes).
Zeos works just fine.
This possibly happens because you have a user "root@localhost" which is created during installation.
Not sure what happens there. Might have to do with the ADO .Net provider. Again - please read up on MySQL and its usernames. This is an error generated by MySQL.svtdoug wrote: ↑15.11.2021, 01:38 I have another app developed in C# which accesses same MySQL server on dev machine which i can access from 2nd computer, and it runs fine. So I know my MySQL server and the credentials are working properly. I just would rather develop in Delphi! Also, I can point this C# app on dev computer to its own IP address (192.168.2.15) and that works. Anyone have thoughts as to what may be causing the error?
Best regards,
Jan
Re: Can't connect to MySQL server on LAN
Good news for you - these restrictions only apply to components shipped with Delphi. Zeos works exactly the same if installed on Delphi 10.4.2 Community or a Lazarus IDE.
Access denied means that the TCP connection was established successfully, so we ruled firewalls out.
In MySQL, usernames and passwords aren't the only protection, you can actually specify FROM WHERE these credentials are considered as valid. Please make sure that your MySQL allows the user "root" to connect from the IP address of the machine your Delphi is running on.
This opens up a huge security vulnerability though, so I'd advise to create a new user for your testing apps and give read / write access ONLY on specific databases from host '%' (wildcard, means user will be able to connect from anywhere). Even if someone gets access, they cannot drop tables / change layout. Data can always be reimported from backups.
Delphi 12.2, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmysql.dll 8.0.40 x64 5.7.19 x68, libmariadb.dll 3.3.11
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.15
- MSSQL 2012, 2019; sybdb.dll FreeTDS_3102
- SQLite 3.47
Using:
- MySQL server 8.0.18; libmysql.dll 8.0.40 x64 5.7.19 x68, libmariadb.dll 3.3.11
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.15
- MSSQL 2012, 2019; sybdb.dll FreeTDS_3102
- SQLite 3.47
Re: Can't connect to MySQL server on LAN
THANK YOU! Michal, Jan and AE for your insight! It was the MySQL root user - Limit to Hosts Matching = localhost that was preventing me from accessing from another machine. I just made a new user and assigned it wildcard % for Host Matching. Presto.
Thanks again for your help. Zeos components are working great. Me happy camper!
Doug
Thanks again for your help. Zeos components are working great. Me happy camper!
Doug
Re: Can't connect to MySQL server on LAN
Glad it worked out :)
Delphi 12.2, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmysql.dll 8.0.40 x64 5.7.19 x68, libmariadb.dll 3.3.11
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.15
- MSSQL 2012, 2019; sybdb.dll FreeTDS_3102
- SQLite 3.47
Using:
- MySQL server 8.0.18; libmysql.dll 8.0.40 x64 5.7.19 x68, libmariadb.dll 3.3.11
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.15
- MSSQL 2012, 2019; sybdb.dll FreeTDS_3102
- SQLite 3.47