从昨天开始,连接到mysql时出现这个错误:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
我还没有碰到我的设置〜1个月,所以我不相信它是由我试图做的任何改变的驱动。 当我尝试重新启动mysql服务
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.
如果我尝试:
sudo service mysqld restart
我只是得到:
Stopping mysqld: [ OK ] MySQL Daemon failed to start. Starting mysqld: [FAILED]
我认为它的一个权限问题根据我读过的其他服务器故障线程有关相同的错误,但我仍然难倒,因为我应该有权限执行该目录中的文件:
drwxr-xr-x 6 mysql mysql 4096 Jun 21 16:42 /var/lib/mysql
更新:下面的日志。 看起来像记忆问题,但我不知道如何解决:
140618 20:17:46 mysqld_safe Number of processes running now: 0 140618 20:17:46 mysqld_safe mysqld restarted 140618 20:17:47 [Note] Plugin 'FEDERATED' is disabled. 140618 20:17:47 InnoDB: The InnoDB memory heap is disabled 140618 20:17:47 InnoDB: Mutexes and rw_locks use GCC atomic builtins 140618 20:17:47 InnoDB: Compressed tables use zlib 1.2.7 140618 20:17:47 InnoDB: Using Linux native AIO 140618 20:17:47 InnoDB: Initializing buffer pool, size = 128.0M InnoDB: mmap(137363456 bytes) failed; errno 12 140618 20:17:47 InnoDB: Completed initialization of buffer pool 140618 20:17:47 InnoDB: Fatal error: cannot allocate memory for the buffer pool 140618 20:17:47 [ERROR] Plugin 'InnoDB' init function returned error. 140618 20:17:47 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 140618 20:17:47 [ERROR] Unknown/unsupported storage engine: InnoDB 140618 20:17:47 [ERROR] Aborting 140618 20:17:47 [Note] /usr/libexec/mysqld: Shutdown complete 140618 20:17:47 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended 140621 16:42:49 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 140621 16:42:49 [Note] Plugin 'FEDERATED' is disabled. 140621 16:42:49 InnoDB: The InnoDB memory heap is disabled 140621 16:42:49 InnoDB: Mutexes and rw_locks use GCC atomic builtins 140621 16:42:49 InnoDB: Compressed tables use zlib 1.2.7 140621 16:42:49 InnoDB: Using Linux native AIO 140621 16:42:50 InnoDB: Initializing buffer pool, size = 128.0M InnoDB: mmap(137363456 bytes) failed; errno 12 140621 16:42:50 InnoDB: Completed initialization of buffer pool 140621 16:42:50 InnoDB: Fatal error: cannot allocate memory for the buffer pool 140621 16:42:50 [ERROR] Plugin 'InnoDB' init function returned error. 140621 16:42:50 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 140621 16:42:50 [ERROR] Unknown/unsupported storage engine: InnoDB 140621 16:42:50 [ERROR] Aborting 140621 16:42:50 [Note] /usr/libexec/mysqld: Shutdown complete 140621 16:42:50 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
更新:在这里find了设置交换文件的答案。 我跟随如何做到这一点的全部细节可以在这里find: http : //www.prowebdev.us/2012/05/amazon-ec2-linux-micro-swap-space.html
你需要确保所有的mysql文件都是由mysql用户拥有的。 validationmysql日志文件是否属于MySQL用户。
ls -l /var/log/mysql*
如果没有设置正确的所有者:
chown mysql:mysql /var/log/mysql....
对my.cnf中列出的所有目录执行相同操作:
root# grep mysql /etc/mysql/my.cnf [mysqld] user = mysql pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock datadir = /data/mysql log_bin=/data/mysql/binlogs/mysql-bin.log slow_query_log_file=/var/log/mysql_slow_query.log log-error=/var/log/mysql_error.log innodb_data_home_dir = /data/mysql
对于目录使用recursion的chown:
chown mysql:mysql -R /data/mysql