Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql running but cannot connect to 127.0.0.1

I have installed mysql55-server using macports.

I can start the server successfully via:

$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql55-server.plist

And confirm I am running the correct mysql:

$ which mysql 

/opt/local/lib/mysql55/bin/mysql

If I run $mysql, I can connect successfully. If I then run:

mysql> show databases;

It shows two databases.

Using Sequel Pro, I can connect via socket:

u: root
p: root
Socket: /opt/local/var/run/mysql55/mysqld.sock

Connects and loads up the databases just fine.

The problem is connecting via 127.0.0.1 or localhost.

If I try to connect using either through standard connection in Sequel Pro, I get:

Unable to connect to host 127.0.0.1, or the request timed out.

Be sure that the address is correct and that you have the necessary privileges, or try increasing the connection timeout (currently 10 seconds).

MySQL said: Can't connect to MySQL server on '127.0.0.1' (61)

So it seems the mysql server is not identified as 127.0.0.1. In my hosts file I have local host listed as 127.0.0.1

127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost 
fe80::1%lo0 localhost 

Also if I try to run:

$ mysql -h 127.0.0.1 -u root

I get:

ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (61)

I have the same setup on Mavericks which works fine. I have updated to Yosemite on another computer and are experiencing these problems. I have tried to cross check all settings between machines. It all seems to matchup. Why would localhost, 127.0.0.1, not be connecting, even though the server is running?

UPDATE

Per @Marc B and neverpanic, I changed my.cnf (/opt/local/etc/mysql55/my.cnf). I removed the include to pull data from the original config file at the top and commented out skip-networking:

[client]
port                   =  3306
socket                 = /opt/local/var/run/mysql55/mysqld.sock
default-character-set  =  utf8

[mysqld_safe]
socket                 = /opt/local/var/run/mysql55/mysqld.sock
nice                   =  0 
default-character-set  = utf8

[mysqld]
socket                 =  /opt/local/var/run/mysql55/mysqld.sock
port                   = 3306
bind-address           =  127.0.0.1
skip-external-locking
#skip-networking

character-set-server   =  utf8

[mysqldump]
default-character-set  =  utf8

Restarted mysql and it worked.

like image 936
Carey Estes Avatar asked Oct 23 '14 21:10

Carey Estes


1 Answers

MacPorts versions of MySQL disable networking using the skip-networking setting by default to allow side-by-side installation of multiple versions of MySQL (which is possible when using sockets, but impossible with TCP ports).

Adjust your MySQL configuration file to enable networking. See also the output of port notes mysql55.

like image 186
neverpanic Avatar answered Oct 08 '22 16:10

neverpanic