![Mysql5.5服务器不工作](https://linux22.com/image/860087/Mysql5.5%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%8D%E5%B7%A5%E4%BD%9C.png)
我的系统上安装了 Ubuntu 14.04。我最近更新了 ubuntu,现在我的 mysql 无法启动,workbench 显示 mysql 服务器已停止。当我尝试启动时,它给出了以下错误
2014-08-12 23:02:04 - Checking server status...
2014-08-12 23:02:04 - Trying to connect to MySQL...
2014-08-12 23:02:04 - Can't connect to MySQL server on '127.0.0.1' (111) (2003)
2014-08-12 23:02:04 - Assuming server is not running
2014-08-12 23:02:04 - Server start done.
2014-08-12 23:02:04 - Checking server status...
2014-08-12 23:02:04 - Trying to connect to MySQL...
2014-08-12 23:02:04 - Can't connect to MySQL server on '127.0.0.1' (111) (2003)
2014-08-12 23:02:04 - Assuming server is not running
而且当我尝试使用终端(mysql -u root -p <password>
)登录时出现以下错误:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
我也尝试过重新安装 Ubuntu,但无法成功。出现以下错误:
Reading package lists... Done
Building dependency tree
Reading state information... Done
mysql-server-5.5 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
由于无法登录服务器,我有一些尚未备份的数据。我是新手,请帮我解决这个问题,不要丢失我的数据。
等待您尽早的回复。
以下是来自 cat /var/log/mysql/error.log 的错误消息
140813 21:22:50 [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.
140813 21:22:50 [Note] Plugin 'FEDERATED' is disabled.
140813 21:22:50 InnoDB: The InnoDB memory heap is disabled
140813 21:22:50 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140813 21:22:50 InnoDB: Compressed tables use zlib 1.2.8
140813 21:22:50 InnoDB: Using Linux native AIO
140813 21:22:50 InnoDB: Initializing buffer pool, size = 128.0M
140813 21:22:50 InnoDB: Completed initialization of buffer pool
140813 21:22:50 InnoDB: highest supported file format is Barracuda.
140813 21:22:50 InnoDB: Waiting for the background threads to start
140813 21:22:51 InnoDB: 5.5.38 started; log sequence number 80726593570
140813 21:22:51 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
140813 21:22:51 [Note] - '127.0.0.1' resolves to '127.0.0.1';
140813 21:22:51 [Note] Server socket created on IP: '127.0.0.1'.
140813 21:22:51 [ERROR] Fatal error: Can't open and lock privilege tables: Incorrect file format 'user'
答案1
我要感谢 Salem,他非常乐于助人,为我的问题提出了各种解决方案。
我无法使用这些建议解决我的问题。而且我有一些非常重要的数据,我不想丢失它们。
这是我最终做的事情
- 创建了一份副本
/var/lib/mysql
,这帮助我找回了所有表格和里面的数据,而无需再次导入数据。
要获取访问 mysql 中的文件和文件夹的权限,请运行以下命令:
sudo chmod 777 /var/lib/mysql
要获取访问 mysql 文件夹内的文件的权限,请运行以下命令:
sudo chmod 777 /var/lib/mysql/*
使用以下命令删除/卸载 mysql:
sudo apt-get remove --purge mysql-server mysql-client mysql-common sudo apt-get remove --purge mysql-client-core-5.5 sudo apt-get autoremove sudo apt-get autoclean sudo rm -rf /var/lib/mysql
我必须单独删除 mysql-client-core-5.5,即使我使用了它autoremove
,autoclean
因为当我设置 root 密码时它总是给我一个错误,因为它说无法创建 root 用户。
安装/重新安装 mysql 服务器和客户端
sudo apt-get install mysql-server sudo apt-get install mysql-client sudo apt-get install mysql-workbench
将所需的文件(包含与我的数据库名称相关的文件的文件夹)复制回该
/var/lib/mysql
文件夹。
确保不要替换新安装中的基础文件。因为这会再次引发相同的问题,即服务器再次停止运行。