MySQL Connection Fail on Mac OS X 9

247 views
Skip to first unread message

Andy Anderson

unread,
Jun 21, 2014, 2:54:22 PM6/21/14
to stacks...@googlegroups.com
This is not a Stacks question per se, but it's keeping me from using Stacks so I thought I would ask it here in case anyone else has come across it and figured it out.
(I already asked a php-oriented version on, appropriately, http://stackoverflow.com/questions/23943321/mdb2-failure-to-connect-to-mysql-on-osx-mavericks )

Configuration:

Mac OS X 10.9.3
PHP 5.4.24 (default)
Stacks 1.19
MySQL 5.6.17
pear list
: MDB2 2.4.1 stable MDB2_Driver_mysql 1.4.1 stable PEAR 1.9.4 stable

I have a database in place on localhost and it's accessible with a particular account and password:

% mysql -u stacks -p password
mysql> use redseaexp_radtags;
Database changed
mysql> show tables
+-----------------------------+  
| Tables_in_redseaexp_radtags |  
+-----------------------------+  
| alleles                     |  
| batches                     |  
| catalog_alleles             |  
| catalog_annotations         |  
| catalog_genotypes           |  
| catalog_snps                |  
| catalog_tags                |  
| chr_index                   |  
| fst                         |  
| ...                         |  
+-----------------------------+  
21 rows in set (0.00 sec)
However, when I try to connect to the database with Stacks (or with similar php on the command line) I get an error message:
File: /usr/local/share/stacks/php/db_functions.php (line 42) MDB2 Error: connect failed. connect: [Error message: No such file or directory] [Native code: 2002] [Native message: No such file or directory] ** mysql(mysql)://stacks:xxx@localhost/redseaexp_radtags
These error messages result from the MDB2 connection, using code from Stacks on the command line:

php > require_once("/usr/local/share/pear/MDB2.php");

php > require_once("constants.php");

php > $database = "redseaexp_radtags";

php > $dsn = 'mysql://' . $db_user . ':' . $db_pass . '@' . $db_host . '/' . $database ;

php > echo($dsn . "\n");

mysql://stacks:password@localhost/redseaexp_radtags

php > $options = array();

php > $dbh = MDB2::connect($dsn, $options);

Thanks for any assistance.
-- Andy

Nathan Dunn

unread,
Jun 24, 2014, 1:02:46 PM6/24/14
to stacks...@googlegroups.com

2 thoughts:
1 - have you tried vStacks (if you are running 10.9)?  (https://itunes.apple.com/us/app/vstacks/id853862589?mt=12)
2 - I am curious if "localhost" is the correct server? 

Julian Catchen

unread,
Jun 24, 2014, 1:14:03 PM6/24/14
to stacks...@googlegroups.com, andyand...@gmail.com
Hi Andy,

How did you install your MDB2 components? Often things on OSX get messed up when people use a combination of packages installed using Apple's tools (which end up in the /usr path) and some packages from a package manager, such as macports or homebrew (which end up in /opt/local). So then the paths for Apache end up looking in /usr and not finding the pieces installed under /opt.

julian

Andy Anderson

unread,
Jun 24, 2014, 1:18:40 PM6/24/14
to stacks...@googlegroups.com

Yes, localhost is the correct server. I can login with

      mysql -u stacks -p password -h localhost redseaexp_radtags

for the same result.

I have not tried vStacks. At $50 I thought I’d try to get the free version going first.

-- Andy

Andy Anderson

unread,
Jun 24, 2014, 1:29:24 PM6/24/14
to stacks...@googlegroups.com, andyand...@gmail.com, jcat...@uoregon.edu
MDB2 was installed using PEAR. It’s loaded with

require_once("/usr/local/share/pear/MDB2.php");

without complaint. I can’t remember now if that location’s different than Stacks’ default; if so, it wasn’t pointing to anything useful, i.e. I don’t believe that Mac OS’ php installation includes MDB2.

-- Andy

Julian Catchen

unread,
Jun 24, 2014, 1:47:39 PM6/24/14
to stacks...@googlegroups.com, andyand...@gmail.com
Hi Andy,

I think you need to have the beta version installed due to a bug. Here is what I have installed:

% pear list
Installed packages, channel pear.php.net:
=========================================
MDB2               2.5.0b3 beta
MDB2_Driver_mysql  1.5.0b3 beta
MDB2_Driver_mysqli 1.5.0b3 beta
PEAR               1.9.4   stable

I haven't seen the "file not found" error before with respect to MDB2, so I wonder if it needs to be in /usr/share instead of /usr/local/share? The Stacks PHP code calls:

require_once("MDB2.php");

while your test called:

require_once("/usr/local/share/pear/MDB2.php");

So I wonder if PHP isn't looking under /usr/local/ when running under Apache?

julian

Andy Anderson wrote:

php > require_once("/usr/local/share/pear/MDB2.php");

php & gt; require_once("constants.php");

php > $database = "redseaexp_radtags";

php > $dsn = 'mysql://' . $db_user . ':' . $db_pass . '@' . $db_host . '/' . $database ;

php > echo($dsn . "\n");

mysql://stacks:password@localhost/redseaexp_radtags

php > $options = array();

<
p style="margin-bottom:0px;font-size:11px;line-height:normal;font-family:Menlo">php > $dbh = MDB2::connect($dsn, $options);

Andy Anderson

unread,
Jul 3, 2014, 4:15:08 PM7/3/14
to stacks...@googlegroups.com
OK, I found the answer: the file that's missing is the mysql socket file; even though this was a mysql-for-mac installation, it doesn't use the right one. I finally found instructions here to correct it:


- Andy
Reply all
Reply to author
Forward
0 new messages