MySQL安装错误:无法为MySQL的“root”用户设置密码。

3
许多人都遇到了这个错误,但是对于我的情况,没有提供的解决方案可行。在我的Ubuntu 14.04服务器上,mysql-server 5.5运行良好,由于某些原因,我们的两个人尝试升级到5.6,在一些混乱的操作后,他们失败了,只安装了5.6-client和mysql-commn,所以我实际上不知道他们的详细操作,然后我尝试像这样降级回5.5:
killall -9 mysql
killall -9 mysqld
apt-get purge mysql-*
remove /etc/myql
apt-get install mysql-sever-5.5

出现错误:

 ┌───────────────────────Configuring mysql-server-5.5─────────────────────────┐ 
 │ Unable to set password for the MySQL "root" user                           │ 
 ├────────────────────────────────────────────────────────────────────────────┤

和以下安装日志:

Setting up mysql-server-core-5.5 (5.5.54-0ubuntu0.14.04.1) ...
Setting up mysql-server-5.5 (5.5.54-0ubuntu0.14.04.1) ...
170218  2:15:57 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
170218  2:15:57 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
170218  2:15:57 [Note] /usr/sbin/mysqld (mysqld 5.5.54-0ubuntu0.14.04.1) starting as process 9038 ...
start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing package mysql-server-5.5 (--configure):
 subprocess installed post-installation script returned error exit status 1
Processing triggers for libc-bin (2.19-0ubuntu6.7) ...
Errors were encountered while processing:
 mysql-server-5.5
E: Sub-process /usr/bin/dpkg returned an error code (1)

类似这样的错误日志:

 170218  2:15:57 [ERROR] /usr/sbin/mysqld: Incorrect information in file: './mysql/tables_priv.frm'
ERROR: 1033  Incorrect information in file: './mysql/tables_priv.frm'
170218  2:15:57 [ERROR] Aborting

170218  2:15:57 [Note] /usr/sbin/mysqld: Shutdown complete

170218  2:15:57 [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.
170218  2:15:57 [Note] Plugin 'FEDERATED' is disabled.
170218  2:15:57 InnoDB: The InnoDB memory heap is disabled
170218  2:15:57 InnoDB: Mutexes and rw_locks use GCC atomic builtins
170218  2:15:57 InnoDB: Compressed tables use zlib 1.2.8
170218  2:15:57 InnoDB: Using Linux native AIO
170218  2:15:57 InnoDB: Initializing buffer pool, size = 128.0M
170218  2:15:57 InnoDB: Completed initialization of buffer pool
InnoDB: Error: log file ./ib_logfile0 is of different size 0 50331648 bytes
InnoDB: than specified in the .cnf file 0 5242880 bytes!
170218  2:15:57 [ERROR] Plugin 'InnoDB' init function returned error.
170218  2:15:57 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
170218  2:15:57 [ERROR] Unknown/unsupported storage engine: InnoDB
170218  2:15:57 [ERROR] Aborting

170218  2:15:57 [Note] /usr/sbin/mysqld: Shutdown complete

所以,如何解决这个问题?欢迎任何建议。
2个回答

6

请执行以下操作:

sudo -i
service mysql stop
killall -KILL mysql mysqld_safe mysqld
apt-get --yes purge mysql-server mysql-client
apt-get --yes autoremove --purge
apt-get autoclean
deluser --remove-home mysql
delgroup mysql
rm -rf /etc/apparmor.d/abstractions/mysql /etc/apparmor.d/cache/usr.sbin.mysqld /etc/mysql /var/lib/mysql /var/log/mysql* /var/log/upstart/mysql.log* /var/run/mysqld
updatedb
exit

您可能还需要使用 dpkg -l | grep mysql 命令列出已安装的 MySQL 包,然后对每个条目执行例如 sudo apt-get purge mysql-common 的操作。

如果已完成上述步骤,并且在运行 dpkg -l | grep mysql 时没有任何 MySQL 引用,则可以尝试使用以下命令进行安装:

sudo apt-get install mysql-server-5.5

1
@Pulkit,似乎在sudo apt-get install mysql-sever-5.5中有一个笔误。你漏掉了'mysql-server-5.5'中的'r'。 - sunitj

2

我面临着在Ubuntu 16.04 LTS上安装MySQL版本5.6的相同问题。经过搜索和与朋友交流,我找到了如何在没有错误的情况下安装它。

首先备份您的数据库,然后按照以下命令操作:

$ sudo apt-get remove --purge *mysql/*
$ sudo apt-get autoremove
$ sudo apt-get autoclean
$ sudo rm -rf /var/lib/mysql
$ sudo apt install mysql-server-5.6
$ sudo apt install mysql-client-5.6

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接