Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have been fiddling around with a problem for a while now, and hope you can help me. Have searched for previous solutions, but nothing seems to work.

My problem is as follows:

I have XAMPP installed on my Mac, as I use it as a localhost for some webpages. One day I got the idea that I wanted to connect Mathematica to the MySQL database, such that I could pull some data from the database, and work with it.

I have tried, following the documentation, and write:

JDBCDriver["Name" -> "MySQL(Connector/J)", 
 "Driver" -> "com.mysql.jdbc.Driver", "Protocol" -> "jdbc:mysql://", "Version" -> 2., 
 "Description" -> "MySQL using Connector/J - Version 5.1.13 - This supports all known 
     MySQL server versions.", "Location" -> "/Applications/
OpenSQLConnection[ JDBC["MySQL(Connector/J)", "localhost:3306/kbm"], 
                   "Username" -> "username", "Password" -> "*******"]
During evaluation of In[6]:= 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 am certain that MySQL listens on pot 3306, I am certain that the database "kbm" exists, and I am certain that username and password is correct. So why doesn't it connect?

I have with success connected to the MySQL database through Terminal, and can conclude that it works. I have also read somewhere that sometimes replacing "localhost" by works, but having tried that out, it still didn't work.

Hope someone can help.


The file looks as follows:

/* Authentication type */
# commented out by xampp security
#$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
/* Server parameters */
//$cfg['Servers'][$i]['host'] = 'localhost';
//$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysql if your server does not have mysqli */
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true;

* phpMyAdmin configuration storage settings.

/* User used to manipulate with storage */
// $cfg['Servers'][$i]['controlhost'] = '';
$cfg['Servers'][$i]['controluser'] = 'pma';
# commented out by xampp security
#$cfg['Servers'][$i]['controlpass'] = '';
$cfg['Servers'][$i]['controlpass'] = '*******';

The rest is commented out.

share|improve this question
What does your config file in PHPAdmin look like? i.e. what address and port are showing? – Mike Honeychurch Oct 22 '13 at 10:07
Have updated the post above. Hope it helps. Could it be because the $cfg['Servers'][$i]['host'] = 'localhost'; is commented out? – Simon P Oct 22 '13 at 10:26
I recall having a problem many years ago trying to connect to MAMP but do not exactly recall the issue. silly question but are you actually running the webserver? – Mike Honeychurch Oct 22 '13 at 20:55
Yes. My Apache Web Server is up and running :-) – Simon P Oct 22 '13 at 21:38
In the past I have had to update the MySQL connector in order for Mathematica to be able to connect. You might want to try that. – Gustavo Delfino Dec 11 '15 at 14:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.