Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

So, I am running mysql on an ubuntu server (command-line) VirtualBox, on a Windows 7 host. In the Virtual machine, I changed the /etc/mysql/my.cnf file by commenting out the line

bind-address = 127.0.0.1

so it looks like

#bind-address = 127.0.0.1

I then restarted the server like so:

perrin@LinuxServer1:~$ sudo /etc/init.d/mysql restart
[sudo] password for perrin:
 * Stopping MySQL database server mysqld    [ OK ]
 * Starting MySQL database server mysqld    [ OK ]

After this, I started getting this error whenever I try to connect to mysql, like so:

perrin@LinuxServer1:~$ mysql -u root -p
Enter password:
Error 2002 (HY000): Can't connect to local MySQL server through socket '/var/
run/mysqld/mysqld.sock' (2)

I searched for help and found out that my MySQL server was NOT running, even though it had SAID [ OK ] when starting back up. (lying P.O.S.)

So I try to start it, using both start and restart like so:

perrin@LinuxServer1:~$ sudo /etc/init.d/mysql start
 * Starting MySQL database server mysqld    [fail]
perrin@LinuxServer1:~$ sudo /etc/init.d/mysql restart
 * Stopping MySQL database server mysqld    [ OK ]
 * Starting MySQL database server mysqld    [fail]

So I go back to the my.cnf and un-comment the bind-address = 127.0.0.1 line, so that everything is EXACTLY as it was before, and try again to start/restart the server. It fails again in exactly the same way.

I've searched all over the web for help and found a few SIMILAR problems people were having, but nothing ultimately useful, or that gave me any tips that led to a solution.

Does anyone have any idea what is going on here? I'm stumped.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

In the list of related questions here on AskUbuntu, I noticed one titled "12.04 - MySql won't start by using service mysql start".

Reading this alerted me to the fact that MySQL can be stopped/started/restarted with:

perrin@LinuxServer1:~$ sudo service mysql stop

or

perrin@LinuxServer1:~$ sudo service mysql start

or

perrin@LinuxServer1:~$ sudo service mysql restart

These methods worked for me, even after commenting out the bind-address line in my.cnf, and I can now log into mysql again after starting/restarting it up.

It just bugs me that I don't know why the init.d method doesn't work. :(

share|improve this answer
    
You are a genius. This EXACT same thing happened to me and I just spent 3 hours troubleshooting. Cheers to you! –  Allen Gingrich Aug 30 at 17:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.