Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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:

Needs["DatabaseLink`"];
JDBCDrivers["MySQL(Connector/J)"]
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/Mathematica.app/
     SystemFiles/Links/DatabaseLink/DatabaseResources/mysql.m"]
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. >>

$Failed

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 127.0.0.1 works, but having tried that out, it still didn't work.

Hope someone can help.

Edit

The config.inc.php 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

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.