Mysql works but cannot connect to 127.0.0.1

I installed a mysql55 server using macports.

I can start the server using:

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

And confirm that 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 ran:

 mysql> show databases; 

It displays two databases.

Using Sequel Pro, I can connect via a socket:

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

Connecting and loading databases is just fine.

The problem is connecting through 127.0.0.1 or localhost.

If I try to connect through a 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 that the mysql server is not identified as 127.0.0.1. In my hosts file, I have a local host specified 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): Cannot connect to MySQL server on "127.0.0.1" (61)

I have the same setup on Mavericks, which works fine. I updated Yosemite on another computer and am experiencing these problems. I tried to cross-check all settings between machines. It all sounds like a match. Why localhost, 127.0.0.1, will not connect even if the server is running?

UPDATE

Per @Marc B and neverpanic, I changed my.cnf (/opt/local/etc/mysql55/my.cnf). I removed include to pull data from the source configuration file at the top and commented on 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 

Restarting mysql and it worked.

+5
source share
1 answer

MacPorts version of MySQL disables networking using the default skip-networking option to allow the parallel installation of multiple versions of MySQL (which is possible with sockets, but not with TCP ports).

Correct the MySQL configuration file to enable networking. See also output from port notes mysql55 .

+5
source

Source: https://habr.com/ru/post/1205404/


All Articles