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.

I tried installing mysql server a couple of times and I'm having problems. First of all, when I install it gives me a message that it's setting up and it just hangs. I can't ctl + c out of it, so I reboot the server and try to log into the db with

sudo mysql -u root -p

I enter my password and then get

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

I restart the server:

$ sudo /etc/init.d/mysql start
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql start

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start mysql

I try this:

$ aptitude search mysql | grep ^i
i A libdbd-mysql-perl               - Perl5 database interface to the MySQL data
i   libmysql-java                   - Java database (JDBC) driver for MySQL     
i A libmysqlclient16                - MySQL database client library             
i   mysql-client-5.1                - MySQL database client binaries            
i A mysql-client-core-5.1           - MySQL database core client binaries       
i   mysql-common                    - MySQL database common files, e.g. /etc/mys
i   mysql-embedded                  - MySQL - embedded library                  
i   mysql-server-core-5.1           - MySQL database server binaries 

When I navigate to the folder to see if the *.sock file exists:

'/var/run/mysqld/mysqld.sock'

it does not. I also try this:

$ service mysql status
status: Unable to connect to system bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory

Any ideas? On my other machines installing mysql has been a snap, not sure what the problem is here.

share|improve this question

2 Answers 2

You've corrupted your packages I see. You said you cancelled the installation of MySQL server, which is the package mysql-server-5.1.

Try clearing your MySQL configuration and reinstalling it:

sudo rm -rf /etc/mysql /var/lib/mysql
sudo apt-get install mysql-server-5.1

Note that the first command clears previous settings and passwords of the MySQL database including the MySQL database itself. If you've just installed the server (as I can make up from your question), this is not an issue.


As SpamapS noticed, you can use apt's purge feature to get rid of the MySQL server and its settings. The commands for purging and installing follows:

sudo apt-get --purge remove mysql-server-5.1
sudo apt-get install mysql-server-5.1
share|improve this answer
1  
Might want to purge the package first before doign those rm -rf's. The files in /etc will stay deleted if the package is still installed. –  SpamapS Mar 31 '11 at 19:39

Does the file mysqld.sock exist? If not, try the following:

sudo mkdir /var/run/mysqld
sudo touch /var/run/mysqld/mysqld.sock
sudo chown -R mysql /var/run/mysqld
share|improve this answer
    
Are you known with MySQL? The socket file is a special file created by MySQL server, you cannot just create it. –  Lekensteyn Mar 18 '11 at 8:49
    
Yeah, i have done some troubleshooting MySql in my days. Actually i googled the issue and found an solution with the above stated answer. It's not that it would break the users system by creating that file. Anyway, sorry that I was trying to help... –  mount.cifs Mar 18 '11 at 9:37
    
    
@mount.cifs: that makes sense, removed downvote. But if it's a permission related issue, only /var/run/mysqld/ should be created and chowned to mysql. Let MySQL server create the socket file by restarting it. –  Lekensteyn Mar 18 '11 at 11:55
    
Hi,I tried this and did not work. I'm still getting the .sock error, as before –  badperson Mar 19 '11 at 11:56

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.