-1

Recently, I've started getting this error when trying to login to mysql:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)

I read on another threat that this can be caused by system getting out of date so I ran all the system updates but that did not work. So I moved onto a restart of mysql might work so I tried this but ran into permissions issues:

service mysqld restart
Stopping mysqld:                                           [  OK  ]
touch: cannot touch ‘/var/log/mysqld.log’: Permission denied
chown: changing ownership of ‘/var/log/mysqld.log’: Operation not permitted
chmod: changing permissions of ‘/var/log/mysqld.log’: Operation not permitted
chown: changing ownership of ‘/var/lib/mysql’: Operation not permitted
chmod: changing permissions of ‘/var/lib/mysql’: Operation not permitted
MySQL Daemon failed to start.
Starting mysqld:                                           [FAILED]

I changed permissions on mysqld.log to 644 but still get the same error. And on review of the log file I also don't understand what might be causing the issue. Here is contents of mysqld.log file:

130427 21:48:58 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
130427 21:48:58 [Note] Plugin 'FEDERATED' is disabled.
130427 21:48:58 InnoDB: The InnoDB memory heap is disabled
130427 21:48:58 InnoDB: Mutexes and rw_locks use GCC atomic builtins
130427 21:48:58 InnoDB: Compressed tables use zlib 1.2.5
130427 21:48:58 InnoDB: Using Linux native AIO
130427 21:48:59 InnoDB: Initializing buffer pool, size = 128.0M
130427 21:48:59 InnoDB: Completed initialization of buffer pool
InnoDB: The first specified data file ./ibdata1 did not exist:
InnoDB: a new database to be created!
130427 21:48:59  InnoDB: Setting file ./ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
130427 21:48:59  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...
130427 21:48:59  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: 127 rollback segment(s) active.
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
130427 21:49:00  InnoDB: Waiting for the background threads to start
130427 21:49:01 InnoDB: 5.5.31 started; log sequence number 0
130427 21:49:01 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
130427 21:49:01 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
130427 21:49:01 [Note] Server socket created on IP: '0.0.0.0'.
130427 21:49:01 [Note] Event Scheduler: Loaded 0 events
130427 21:49:01 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.5.31'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL)

If anyone could point me in the right direction I would greatly appreciate it! Thanks.

4
  • What operating system or Linux distribution? Please tag accordingly. Is MySQL from a standard package or self-built? Sep 14 '14 at 20:57
  • MySQL is standard package, not self built. This on an EC2 server with the standard Amazon Linux AMI
    – john k
    Sep 14 '14 at 21:04
  • 1
    You need to fix your logging before you do anything else. Those logs are from the 27th of April.. 2013.
    – user143703
    Sep 15 '14 at 2:32
  • The 644 permissions you mention are not enough to know whether MySQL can write to the file. We also need to know the owner and group of the file and the user MySQL (or the startup script) is running as and the groups that user is a part of. If you are not logged in as root, you will need sudo in front of service mysqld restart.
    – Ladadadada
    Sep 16 '14 at 11:52
3

From the information you gave it seems to be an issue with the user permission in which the MySQL instance is running. Try running the below command and check whether it fixes your issue:

chown -R mysql:mysql /var/lib/mysql

Also check whether MySQL instance is running at your machine by executing the following command:

ps ax | grep mysql

If it is not running try starting it by root privileges using the below command and check

sudo service mysql start

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