I am having a big problem trying to connect to mysql. When I run:
/usr/local/mysql/bin/mysql start
I have the following error :
Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (38)
I do have mysql.sock
under the /var/mysql
directory.
In /etc/my.cnf
I have:
[client]
port=3306
socket=/var/mysql/mysql.sock
[mysqld]
port=3306
socket=/var/mysql/mysql.sock
key_buffer_size=16M
max_allowed_packet=8M
and in /etc/php.ini
I have :
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
mysql.default_socket = /var/mysql/mysql.sock
I have restarted apache using sudo /opt/local/apache2/bin/apachectl restart
But I still have the error.
Otherwise, I don't know if that's relevant but when I do mysql_config --sockets
I get
--socket [/tmp/mysql.sock]
For those whose any solution did not work, try:
check if my.cnf is present
and make sure you have only one bind-address as follows:
bind-address = 127.0.0.1
If not, that might be the problem, just exit nano and save the file.
and
service mysql start
note that if you don't have nano (its a text editor) just install it with
apt-get install nano
and once in just press Ctrl+X to exit, dont forget to say Y to save and use the same file)For me - this was simply a case of MySQL taking a long time to load. I have over 100,000 tables in one of my databases and it did eventually start but obviously has to take a long time in this instance.
As can be seen by the many answers here, there are lots of problems that can result in this error message when you start the MySQL service. The thing is, MySQL will generally tell you exactly what's wrong, if you just look in the appropriate log file.
For example, on Ubuntu, you should check
/var/log/syslog
. Since lots of other things might also be logging to this file, you probably want to usegrep
to look at mysql messages, andtail
to look at only the most recent. All together, that might look like:grep mysql /var/log/syslog | tail -50
Don't blindly make changes to your configuration because someone else said 'This worked for my system.' Figure out what is actually wrong with your system and you'll get a better result much faster.
I had this problem too when trying to start the server, so many of the answers here that just say to start the server didn't work. The first thing you can do is execute the following to see if there are any config errors:
I did have one error that showed up:
A simple
grep -HR "innodb-online-alter-log-max-size" /etc/mysql/
showed me exactly what file contained the offending line, so I removed that line from the file.Then, checking my
/var/log/mysql/error.log
file I had:Based on this question the accepted solution wouldn't work because I couldn't even get the server started, so I followed what some of the comments said and deleted my
/var/lib/mysql/ib_logfile0
and/var/lib/mysql/ib_logfile1
files.This allowed the server to start and I was able to connect and execute queries, however checking my error log file it was quickly getting filled up with several tens of thousands of lines like this:
Based on a suggestion from here, to fix this I did a mysqldump and restore of all databases (see the link for several other solutions).
Everything appears to be working as expected now.
I ran into this issue today. None of these answers provided the fix. I needed to do the following commands (found here https://stackoverflow.com/a/20141146/633107) for my mysql service to start:
This was partly indicated by the following errors in /var/log/mysql/error.log:
I also saw the disk full error, but only when running commands without sudo. If the permissions check fails, it reports disk full (even when your partition is not even close to full).
I used 127.0.0.1 for -h instead localhost and everything was OK. In other case had what had - error that above.