Message Boards Message Boards

JDBC::error when connecting to local MySQL database

I will go right to the problem.

I have a localhost (XAMPP) installed on my computer (Mac). With this installation follows a MySQL server, and I would like to connect to it. But here is what happens:

conn1 = OpenSQLConnection[JDBC["MySQL(Connector/J)", ""],  "Username" -> "root", "Password" -> ""]
The result is get is:
JDBC::error: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. >>


I have checked the following:I am running out of ideas on what to do. This problem has always existed and I have never been able to solve it.

I would be really greatful if someone miraculously know tips and tricks to get it up and running.  
3 years ago
That error is typical when the server does not exist or cannot be reached.  Can you mention what other clients (MySQL Workbench etc.) have been able to connect?

Also:  if your server is running on a non-standard port (i.e. not 3306), you will have to specify it in the connection URL.  The connection command would be something like this:
OpenSQLConnection[JDBC["MySQL(Connector/J)",""], "Username" -> "username", "Password" -> "$Prompt"]
... for port 1234 and database mydatabase.
POSTED BY: Dillon Tracy
3 years ago
A slightly silly suggestion but... you MySQL server running?  

Go to a terminal and simply type


If your mysql server is not running then you will get an error message like 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

And indeed when my mysql server is not running I get the same Mathematica error as you do when attempting to open a connection using DatabaseLink
POSTED BY: David Reiss
3 years ago
Hello Dillon and David,

Thank you both for answering!

For some reason the MySQL server did not allow for external connections from other than, Restarting both Apache and MySQL Server, the computer prompted me to allow or deny external connections. Allowing this, made Mathematica able to connect!

Best Regards

Simon P.
3 years ago

Group Abstract Group Abstract