ubuntu 从 mysql 升级到 maria db

ubuntu 从 mysql 升级到 maria db

首先备份我的所有数据库

mysqldump -u caiofior -p --all-databases > /home/caiofior/all.sql

然后卸载mysql

sudo apt-get purge $(sudo dpkg -l | grep -E 'mysql-(server|client|commom)' | awk '{print $2}')

删除所有配置文件

sudo rm -Rf /etc/mysql
sudo rm -Rf /var/lib/mysql*

然后安装mariadb

sudo apt-get install mariadb-server mariadb-client

还原数据库

sudo mysql < /home/caiofior/all.sql

重新启动 mariadb 服务

sudo service mysql restart

然后它就崩溃了,日志

● mysql.service - LSB: Start and stop the mysql database server daemon
Loaded: loaded (/etc/init.d/mysql; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since mer 2017-06-14 10:26:19 CEST; 12s ago
Docs: man:systemd-sysv-generator(8)
Process: 5885 ExecStart=/etc/init.d/mysql start (code=exited, status=1/FAILURE)

giu 14 10:25:49 portattile-caiofior mysqld[6058]: 170614 10:25:49 [ERROR] Plugin 'blackhole' already installed
giu 14 10:25:49 portattile-caiofior mysqld[6058]: 170614 10:25:49 [ERROR] Plugin 'federated' already installed
giu 14 10:25:49 portattile-caiofior mysqld[6058]: 170614 10:25:49 [ERROR] Plugin 'innodb' already installed
giu 14 10:25:49 portattile-caiofior mysqld[6058]: 170614 10:25:49 [Note] Server socket created on IP: '127.0.0.1'.
giu 14 10:25:49 portattile-caiofior mysqld[6058]: 170614 10:25:49 [ERROR] Fatal error: mysql.user table is damaged or in unsupported 3.20 format.
giu 14 10:26:19 portattile-caiofior mysql[5885]: ...fail!
giu 14 10:26:19 portattile-caiofior systemd[1]: mysql.service: Control process exited, code=exited status=1
giu 14 10:26:19 portattile-caiofior systemd[1]: Failed to start LSB: Start and stop the mysql database server daemon.
giu 14 10:26:19 portattile-caiofior systemd[1]: mysql.service: Unit entered failed state.
giu 14 10:26:19 portattile-caiofior systemd[1]: mysql.service: Failed with result 'exit-code'.

为什么?

答案1

问题出在转储中,我还备份了带有用户和权限的 mysql 数据库,但它导致 maria db 崩溃。

所以恢复数据备份你的mysql数据库数据

sudo mysqldump mysql > /home/caiofior/mysql.sql

恢复所有数据后恢复以前的mysql数据库

sudo mysqladmin drop mysql
sudo mysqladmin create mysql
sudo mysql mysql < /home/caiofior/mysql.sql

相关内容