一、问题描述
mysql进程无法启动
二、问题分析
检查error log,如下:
180105 21:59:12 mysqld_safe mysqld from pid file /Applications/MAMP/tmp/mysql/mysql.pid ended
180105 22:00:30 mysqld_safe Logging to ‘/Applications/MAMP/logs/mysql_error.log’.
180105 22:00:30 mysqld_safe Starting mysqld daemon with databases from /Library/Application Support/appsolute/MAMP PRO/db/mysql56
2018-01-05 22:00:30 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use –explicit_defaults_for_timestamp server option (see documentation for more details).
2018-01-05 22:00:30 0 [Note] –secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2018-01-05 22:00:30 0 [Note] /Applications/MAMP/Library/bin/mysqld (mysqld 5.6.35) starting as process 34383 …
2018-01-05 22:00:30 34383 [Warning] Setting lower_case_table_names=2 because file system for /Library/Application Support/appsolute/MAMP PRO/db/mysql56/ is case insensitive
2018-01-05 22:00:30 34383 [Note] Plugin ‘FEDERATED’ is disabled.
2018-01-05 22:00:30 34383 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-01-05 22:00:30 34383 [Note] InnoDB: The InnoDB memory heap is disabled
2018-01-05 22:00:30 34383 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-01-05 22:00:30 34383 [Note] InnoDB: Memory barrier is not used
2018-01-05 22:00:30 34383 [Note] InnoDB: Compressed tables use zlib 1.2.8
2018-01-05 22:00:30 34383 [Note] InnoDB: Using CPU crc32 instructions
2018-01-05 22:00:30 34383 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-01-05 22:00:30 34383 [Note] InnoDB: Completed initialization of buffer pool
2018-01-05 22:00:30 34383 [Note] InnoDB: Highest supported file format is Barracuda.
2018-01-05 22:00:30 34383 [Note] InnoDB: 128 rollback segment(s) are active.
2018-01-05 22:00:30 34383 [Note] InnoDB: Waiting for purge to start
2018-01-05 22:00:30 34383 [Note] InnoDB: 5.6.35 started; log sequence number 252053935
2018-01-05 22:00:30 34383 [Note] RSA private key file not found: /Library/Application Support/appsolute/MAMP PRO/db/mysql56//private_key.pem. Some authentication plugins will not work.
2018-01-05 22:00:30 34383 [Note] RSA public key file not found: /Library/Application Support/appsolute/MAMP PRO/db/mysql56//public_key.pem. Some authentication plugins will not work.
2018-01-05 22:00:30 34383 [Note] Server hostname (bind-address): ‘127.0.0.1’; port: 8889
2018-01-05 22:00:30 34383 [Note] - ‘127.0.0.1’ resolves to ‘127.0.0.1’;
2018-01-05 22:00:30 34383 [Note] Server socket created on IP: ‘127.0.0.1’.
2018-01-05 22:00:30 34383 [ERROR] Can’t start server : Bind on unix socket: Address already in use
2018-01-05 22:00:30 34383 [ERROR] Do you already have another mysqld server running on socket: /Applications/MAMP/tmp/mysql/mysql.sock ?
2018-01-05 22:00:30 34383 [ERROR] Aborting
2018-01-05 22:00:30 34383 [Note] Binlog end
….省略一系列shutting down plugin的操作
上面提示unix socket /tmp/mysql/mysql.sock 被占用,用ps -ef|grep mysql检查没有其它mysql进程.用netstat -an|grep 8889(你的mysql的端口号)检查端口也不存在。
对比分析,正常关闭mysql时,/tmp/mysql/mysql.sock文件是不存在的,而现在mysql已关闭后,还存在/tmp/mysql/mysql.sock文件。
猜测是由于上次mysql未正常关闭或关闭异常引起。
三.问题解决
在root用户下,删除/tmp/mysql/mysql.sock文件,再重启mysql。