Kyuu
Kyuu

Reputation: 1045

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

Having some trouble creating a mysql connection. The mysql instance is running in system preferences and I have made sure the mysql config file is in the right location(Test settings passed). When I go into Test DB connections I get red cross on all three sections.(open database connections, get server version, get server OS). Running mac 10.10.2. Set connection name as home hostname as 127.0.0.1, port as 3306, username as root, password as my computers root password and default schema as home as well. Any ideas?

Upvotes: 15

Views: 64903

Answers (9)

dan
dan

Reputation: 11

Check your mac version download the corresponding version MySQL Community Server (Archived Versions) 8.011 -- 8.031

Upvotes: 1

aworkinghuman
aworkinghuman

Reputation: 170

The database I use is dependent on DBngin running so this was the error I had. Close your database management tool and then open the DBngin app and start mysql services. Then when you connect it'll have the database appear to allow you to connect

Upvotes: 0

Pri
Pri

Reputation: 11

I had the same issue and I updated following settings on MAMP/MySQL - Allow Network Access to MySQL to "Only From this Mac" and it fixed the issue for me. I have attached a screenshot here. Also port should be updated to 8889 instead of 3306. Allow Network Access

Upvotes: 1

Chris Edwards
Chris Edwards

Reputation: 3602

I just had this and the only solution that worked for me was to remove the ib_logfile* files from /usr/local/var/mysql, similar to Engr.Tanbir Hasan's answer:

cd /usr/local/var/mysql
rm ib_logfile*

Then restart with (I'm using MariaDB, but same applies to MySQL):

brew services restart mariadb
# or
brew services restart mysql

I found the solution here.

Upvotes: 6

user8075070
user8075070

Reputation:

brew install mysql worked for me

Then brew services start mysql

Upvotes: 3

Marcos QP
Marcos QP

Reputation: 772

I had same problem, but it worked for me.

  1. check if you have mysql installed

    enter image description here

If you don't have mysql installed, download from this link: https://dev.mysql.com/downloads/mysql/

  1. follow this instructions to install https://dev.mysql.com/doc/mysql-osx-excerpt/5.7/en/osx-installation-pkg.html

  2. You can test the connection without any problem.

(Sorry for my english, I agree fix me please)

I Hope I've helped. Greetings.

Upvotes: 0

Golam Sorwar
Golam Sorwar

Reputation: 1615

enter image description here

You can see this type of error , try this:

run this command on your iTerm or Terminal:

sudo mysql.server start

If you see some errors like this:

my_print_defaults: Can't read dir of '/usr/local/etc/my.cnf.d' (OS errno 2 - No such file or directory)

my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
Starting MySQL

.my_print_defaults: Can't read dir of '/usr/local/etc/my.cnf.d' (OS errno 2 - No such file or directory)

my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!

my_print_defaults: Can't read dir of '/usr/local/etc/my.cnf.d' (OS errno 2 - No such file or directory)

my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
 ERROR! The server quit without updating PID file (/usr/local/var/mysql/MacBook-Pro.local.pid).

Just make the dir:

mkdir /usr/local/etc/my.cnf.d

and then run it again:

sudo mysql.server start

Works for me.

Upvotes: 7

HM Tanbir
HM Tanbir

Reputation: 1020

  1. Delete pid files using this command:

    $ cd /usr/local/var/mysql
    $ sudo rm -rf [networkname*].err
    $ sudo rm -rf [networkname*].pid
    
    1. Now restart server use brew sevices

    $ brew services restart mysql

∗your network name like "Tanbirs-Mac-mini.local" (use echo $HOST)

Upvotes: 20

Python Basketball
Python Basketball

Reputation: 2370

Today i have come with this issue, i solved it using the following steps:

First, check whether listening to the port 3306:

netstat -tulpen

if it prints the following log, it would be right:

...
tcp6 0 0 :::3306 :::* LISTEN 27 46396 22054/mysqld
...

otherwise, edit the file my.cnf and add the code to it:

bind-address = 0.0.0.0

it means that it listens to all ports.

Secondly, in the CentOS 7 add the Mysql service to firewall:

sudo firewall-cmd --zone=public --permanent --add-service=mysql

it returns Success, and then going on executing the command:

sudo systemctl restart firewalld

Now, it's OK!!!

Upvotes: 3

Related Questions