Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock
I'm getting the following error message:
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' so I ran: find / -name mysql.sock and it doesn't show up, what should I do now? I'm using Mandrake 10.1 and this is the first time I'm using mysql. Should i try uninstalling mysql and reinstalling. I also noticed that there was an error file in /var/lib/mysql which had this in it: 50124 23:05:00 mysqld started ^G/usr/sbin/mysqld: Can't read dir of '/root/tmp/' (Errcode: 13) InnoDB: The first specified data file ./ibdata1 did not exist: InnoDB: a new database to be created! 050124 23:05:00 InnoDB: Setting file ./ibdata1 size to 10 MB InnoDB: Database physically writes the file full: wait... 050124 23:05:01 InnoDB: Log file ./ib_logfile0 did not exist: new to be created InnoDB: Setting log file ./ib_logfile0 size to 5 MB InnoDB: Database physically writes the file full: wait... 050124 23:05:01 InnoDB: Log file ./ib_logfile1 did not exist: new to be created InnoDB: Setting log file ./ib_logfile1 size to 5 MB InnoDB: Database physically writes the file full: wait... InnoDB: Doublewrite buffer not found: creating new InnoDB: Doublewrite buffer created InnoDB: Creating foreign key constraint system tables InnoDB: Foreign key constraint system tables created 050124 23:05:02 InnoDB: Started /usr/sbin/mysqld: ready for connections. Version: '4.0.20' socket: '/var/lib/mysql/mysql.sock' port: 0 050124 23:05:02 /usr/sbin/mysqld: Normal shutdown 050124 23:05:02 InnoDB: Starting shutdown... 050124 23:05:04 InnoDB: Shutdown completed 050124 23:05:04 /usr/sbin/mysqld: Shutdown Complete 050124 23:05:04 mysqld ended |
my.cnf
You can fix all of these problems through my.cnf, which is usually found at /etc/my.cnf
To get rid of those innodb errors (if you don't plan on using innodb), use this: skip-innodb If you don't plan on remote systems attaching directly to your database, and you're also running Apache on the system and want to interface the two, perhaps with a scripting language, enter this as well: skip-networking That will stop MySQL from running on anything but a socket (sockets are faster than tcp/ip access). As for not finding the mysql.sock file, Try: Code:
find / | grep "sock" Once you find it, you can enter the location here: socket = /var/lib/mysql/mysql.sock Just for a reference, here is my "my.cnf". It's a copy of my-medium.cnf (low memory in this system). Quote:
|
thanks. I think all it needed was a reboot
|
Quote:
|
GNU/Linux != Windows
Quote:
If the problem is gone, then great, but it will probably surface again. Those errors mentioned are innodb errors, and adding noinnodb to my.cnf will get rid of those. |
I think the problem was that I jsut installed mysql and the actual process that it needs to run wasn't running. I wasn't exactly sure how to run it. I probably could have ran it with a command of some sort but when i rebooted it started the process again so mysql worked. I still also did add noinnodb to my.cnf and that removed the errors. but the original error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' was cause because mysql process wasn't running
|
Quote:
|
Rebooting? :confused:
|
Quote:
i fixed my system by adding skip-networking skip-innodb to my.cnf |
Why rebooting may work?
Yes we all know rebooting is nooby. However I think it may sort out some problems, such as restarting apache... etc
All I can say is that if restarting is your solution for your linux server you will have learned nothing of why the error had been occuring in the first place. May as well be using XAMPP on your XP box :P |
I'm getting the same error, is there any service that i need to start so i can connect to mysql ?
|
You need to start the mysqld daemon, varies depending upon your distribution. To see if mysql is running, open a terminal and type: ps -e | grep my; if it is not post back with distribution you are using.
|
Need to install mysql-server
I had the same problem after a fresh install of mysql. I fixed it by installing mysql-server, then running /etc/init.d/mysqld start. That worked for me.
|
Quote:
|
my solution
I had this same problem on a Ubuntu 11 virtual machine running on vmware server 2.0. It turned out that I had broken my /etc/network/interfaces file. Once I got the loopback portion of the file corrected, MySQL came back fine.
For me, it was making sure that the following lines were in the /etc/network/interfaces file: auto lo iface lo inet loopback When you connect to MySQL via the local machine using # mysql -uusername -ppassword it tries to connect to 127.0.0.1 (local loopback) However, if you’ve botched your interfaces file as I had, your mysql gets screwed. I tried uninstalling everything mysql but that didn’t work. I even made sure that I went through the entire filesystem and deleted every file and directory with “mysql” in it’s name and then reinstalling. No luck. But when I got my interfaces file corrected, everything was fine. see # man interfaces for a little help on the file. |
All times are GMT -5. The time now is 01:37 AM. |