MySQL isn’t running, and I can’t figure out why. I’m not a back-end developer, so I don’t know very much about MySQL. The project I’m working on is using Ruby with Rails and a MySQL database. I’m the designer and front-end dev trying to view the files locally using webrick (rails local server). I’ve done it successfully once before, but I don’t know why it isn’t working now. This is the error message I get in the terminal when I try to run “rails server” in my project’s directory:
“Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2) (Mysql::Error).”
Since this is a new clone of a project, I went ahead and did a quick bundle install to make sure I had everything I needed. Even after that, I still got the same error message.
Below shows the web I’ve woven so far in trying to figure out the above error message.
From System/usr/local/bin/, I typed:
$sudo ./mysqld_safe &
[1] 6983
$./mysqladmin -u root shutdown
./mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
$ telnet localhost:3306
localhost:3306: nodename nor servname provided, or not known
$ telnet 127.0.0.1:3306
127.0.0.1:3306: nodename nor servname provided, or not known
$ telnet
telnet> quit
That was mostly the Rails developer trying to figure out why it wasn’t working. I’m hoping it’s useful to you as well. His conclusion was that I needed to create a mysql root password to see if that would fix it because I didn’t create one when I first installed mysql. I tried that by doing this:
$mysqladmin -u root password mypassword
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
After that, we thought it might be easier to uninstall mysql altogether and reinstall it. Since I initially installed it using Homebrew, I also uninstalled and reinstalled it the same way, which worked just fine.
$ brew uninstall mysql
$ brew install mysql
Then we tried this again, which had the same error:
$ telnet 127.0.0.1:3306
127.0.0.1:3306: nodename nor servname provided, or not known
$ netstat, however, returned a huge list of things.
The we tried to start the mysql server:
$ mysql.server start
Starting MySQL
.. ERROR! The server quit without updating PID file (/usr/local/var/mysql/Nickis-MacBook-Air.local.pid).
So we tried to remove that file:
$ rm /usr/local/var/mysql/Nickis-MacBook-Air.local.pid
rm: /usr/local/var/mysql/Nickis-MacBook-Air.local.pid: No such file or directory
$ sudo rm /usr/local/var/mysql/Nickis-MacBook-Air.local.pid
rm: /usr/local/var/mysql/Nickis-MacBook-Air.local.pid: No such file or directory
That is the error message I’m left with now, but the one at the top I believe is still relevant.
I really hope someone can help. I’m completely stuck.