mysql 服务器启动失败

ana*_*nth 35 server mysql startup

我正在运行 ubuntu 服务器。当我尝试登录 mysql(正在运行)时,出现以下错误

ERROR 2002 (HY000): Can't connect to local MySQL server through socket         '/var/run/mysqld/mysqld.sock' (2)
Run Code Online (Sandbox Code Playgroud)

但是文件/var/run/mysqld夹中不存在 mysqld.sock 文件。在执行ps aux | grep mysql命令时,我意识到 mysql 服务器没有运行。

然后我尝试使用重新启动mysql服务器

service mysql start
service mysql restart
/etc/init.d/mysql start
Run Code Online (Sandbox Code Playgroud)

但是,启动过程在所有 3 种情况下都失败了。 /var/log/mysql/mysql.log/var/log/mysql/mysql.err文件是空的。

/var/log/error.log显示以下信息:

140425 12:49:05 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
140425 12:49:05 [Note] Plugin 'FEDERATED' is disabled.
140425 12:49:05 InnoDB: The InnoDB memory heap is disabled
140425 12:49:05 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140425 12:49:05 InnoDB: Compressed tables use zlib 1.2.8
140425 12:49:05 InnoDB: Using Linux native AIO
140425 12:49:05 InnoDB: Initializing buffer pool, size = 3.0G
140425 12:49:05 InnoDB: Completed initialization of buffer pool
InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
InnoDB: than specified in the .cnf file 0 26214400 bytes!
140425 12:49:05 [ERROR] Plugin 'InnoDB' init function returned error.
140425 12:49:05 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
140425 12:49:05 [ERROR] /usr/sbin/mysqld: unknown variable 'record_buffer=64M'
140425 12:49:05 [ERROR] Aborting

140425 12:49:05 [Note] /usr/sbin/mysqld: Shutdown complete
Run Code Online (Sandbox Code Playgroud)

job*_*bin 31

打开终端(Ctrl+ Alt+ t),并执行以下:

sudo service mysql stop
sudo rm /var/lib/mysql/ib_logfile0
sudo rm /var/lib/mysql/ib_logfile1
Run Code Online (Sandbox Code Playgroud)

并注释掉线record_buffer=64M/etc/mysql/my.cnf [1]

然后使用以下命令重新启动 msyql:

sudo service mysql restart
Run Code Online (Sandbox Code Playgroud)

(来源)


小智 9

这解决了我的问题:

mkdir /var/run/mysqld

touch /var/run/mysqld/mysqld.sock

chown -R mysql /var/run/mysqld

/etc/init.d/mysql restart

  • 应用这些步骤后,我的数据库被删除了。现在我该怎么办?? (6认同)

Sud*_*M.S 8

我通过以下方式解决了这个问题:

chown -R mysql:mysql /var/lib/mysql
mysql_install_db --user=mysql -ldata=/var/lib/mysql/
Run Code Online (Sandbox Code Playgroud)

在另一种情况下,我遇到它是因为mysql 守护程序无法启动。所以用命令启动守护进程 -mysqld start然后尝试启动服务。