Connection to another MySQL server

I am building a program on a Mac-mini (Intel 2018) in Xojo 2023 r4 which has a connection to a MySQL database via Mamp-Pro. And xojo is using the MySQLCommunityServer. Using Localhost as Host.
Everthing works fine.
The client has told me that the program will be running on two different mac machines and that the database should be running on a different machine.
So I have put together a nice little server with Debian and Apache2, MySQL and PHP. Runs fine in the local network. I can use PHPMyAdmin in a browser.
I have installed DBeaver on my Mac and can connect to the Database server on 192.168.178.99 and port 3306.
I can connect to the Database server on a Linux Mint console:
mysql -u brian -p -h 192.168.178.99 -P 3306
And this works fine.
I had to change the bind-address on the database server and the firewall setting to allow 3306.

But I can not get a connection in my Xojo code.

App.mDb.Host = "192.168.178.99"
App.mDb.Port = 3306
App.mDb.UserName = "User"
App.mDb.Password = "Password"
App.mDb.DatabaseName = "DatabaseName"

FormLoaded = True

Try
  App.mDB.Connect
  App.IsConnected = True
  lblConnectStatus.Value = "Connected to MySQL and User is: " + App.LoggedInUser
Catch e As DatabaseException
  lblConnectStatus.Value = "Error connecting to MySQL: " + e.Message
End Try

I get the error Can’t connect to MySQL server on ‘192.168.178.99’ (65)

If I change the host to a different ip number I get the same error.
But I can connect to the server via DBeaver from the Mac-mini.
And via the console all be it with Brew:
$(brew --prefix mysql-client)/bin/mysql -u brian -p -h 192.168.178.99 -P 3306
But this works, I can connect and run query’s on my mac-mini.

Could somebody put me out of my miseri?

Thanks in advance.
Brian


MySQL server users have a “host” attached. You’ll need to change the user to have a host of “*” (from memory).

As Wayne says mysql user accounts have a host element that only allows connection from that host. There are various options for connections from some but not every address. A host of % (the mysql wildcard symbol) allows connection from any address on the internet, which obviously has security implications. If your hosts are all behind a firewall then you can use that to block the internet as a whole and limit it to just your network.

You can also use wildcard host names. Such as ‘%.example.com’, which would allow access from any computer in the ‘example.com’ domain. Equally you can use wildcard IP addresses, for example ‘198.51.100.%’, allowing connection from any host in the '198.51.100.1-244 range.

The more specific you can be the more secure, but the more problems if you’re user has to work on another machine for a day.

Thank you for you reply.
I have in my mysql setting the bind address set to 0.0.0.0
And the connection to the debian database server is working on another linux mint computer for this user.
And on the mac mini the connection is working in the console.
But not in Xojo, so I am hoping that a setting in Xojo is faulty.

With regards,
Brian

I have checked in phpmyadmin and the user brian has % as host. So he can connect from anywhere.
Also this all local. There are no ports open to the outside of my network.

Brian.

Update:
I have opened the example xojo project: MySQL and I can not connect to the external MySQL server. I can connect to the local MySQL server, with Localhost or with 127.0.0.1.

I am pushing this problem forward. I need to finish the program and when I install it on the computer of the client I will deal with this then.

Unless somebody has an idea where to look?

With regards,
Brian

Update, I have a Windows 10 virtual machine with the same Xojo version 2023R4 and when I run the example project MySQL, the connection is made. To the same Debian PHP/MySQL/Apache2 server.
So the conclusion is so far:
Everything connects except the xojo program on my mac mini.
So its a mac thing


Try a sample using the latest Xojo. Maybe a Xojo Mac MYSQL connector bug of that 2023 edition.

Another update: I have installed version 2025 r4.2 and ran the program connecting to the external MySQL debian machine. And got the same error.
But I ran the example program and this worked. Indeed it worked, the code is the same, I copied that when I wrote my program.
Just before the example program run I had to exept a message from my mac, me being an idiot didn’t really read the message just clicked ok. And the program ran with the connection to my server saying ‘connected’.
Now the search is what was the message

As it doesn’t show up when I rerun the program it is probably the reason why my program doesn’t connect.
Idiot between keyboard and chair.

After a long discussion with my other friend (ChatGTP) he suggested that I look at:
Settings → Network and allow my program to connect to the network.
And it is solved My program connect to the MySQL debian server.

1 Like

Well thanks for that solution!!

We have a similar error with my Xojo CRM application here at the office. Two out of eight computers have this problem (intermittently), so you can understand my frustration. I fiddled with the MuSQL server settings, wrote extensive error catching routines to see where it goes wrong and still came up empty


Until I found this topic! I had the same error with code (65) and was baffled why this happens on only a few computers.

Now I know how to fix it. I guess I need to keep doing it, because at regular intervals I make updates to my software and every time I update the app, MacOS sees it as a new app and all Privacy and Safety settings need to be reset.

Well the problem is that I looked at these settings and the program was allowed. But after turning it off and back on again, I mean the settings, the program worked.

Glad to help somebody else. That is why I gave the answer to my own problem.

That’s the worst behavior of an OS I can imagine. There must be something we can do, like having a way to check this condition and pop a message to the user to fix it by himself in the worst scenario.