我发现 MySQL 5.7 占用大量内存,因此想回滚到 MySQL 5.6。
但是每次我尝试卸载 5.7 并安装 5.6 时,MySQL 服务都无法启动。此外,我还需要确保保留所有数据库。
有人能告诉我如何将 mysql 从 5.7 回滚到 5.6 的简单步骤吗?
**UPDATE**
$ dpkg -l | grep mysql
rc akonadi-backend-mysql 1.13.0-2ubuntu4 all MySQL storage backend for Akonadi
ii dbconfig-mysql 2.0.4ubuntu1 all dbconfig-common MySQL/MariaDB support
ii libdbd-mysql-perl 4.033-1build2 amd64 Perl5 database interface to the MySQL database
rc libmysqlclient18:amd64 5.6.30-0ubuntu0.15.10.1 amd64 MySQL database client library
rc libmysqlclient18:i386 5.6.30-0ubuntu0.15.10.1 i386 MySQL database client library
ii libmysqlclient20:amd64 5.7.12-0ubuntu1.1 amd64 MySQL database client library
ii mysql-client-5.7 5.7.12-0ubuntu1.1 amd64 MySQL database client binaries
ii mysql-client-core-5.7 5.7.12-0ubuntu1.1 amd64 MySQL database core client binaries
ii mysql-common 5.7.12-0ubuntu1.1 all MySQL database common files, e.g. /etc/mysql/my.cnf
iU mysql-server 5.7.12-0ubuntu1.1 all MySQL database server (metapackage depending on the latest version)
rc mysql-server-5.5 5.5.43-0ubuntu0.14.10.1 amd64 MySQL database server binaries and system database setup
rc mysql-server-5.6 5.6.16-1~exp1 amd64 MySQL database server binaries and system database setup
iF mysql-server-5.7 5.7.12-0ubuntu1.1 amd64 MySQL database server binaries and system database setup
ii mysql-server-core-5.7 5.7.12-0ubuntu1.1 amd64 MySQL database server binaries
ii php-mysql 1:7.0+42+deb.sury.org~xenial+2 all MySQL module for PHP [default]
ii php5.6-mysql 5.6.23-1+deb.sury.org~xenial+2 amd64 MySQL module for PHP
ii php7.0-mysql 7.0.8-2+deb.sury.org~xenial+1 amd64 MySQL module for PHP
答案1
首先创建一个mysqldump
包含所有数据库(包括information_schema
)的 。然后“停止”mysql”,这将删除与 mysql 相关的所有内容:
sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-5.7 mysql-client-core-5.7
# Backup 5.6 config and data without deleting
sudo mv /etc/mysql /etc/mysql-5.6-backup
sudo mv /var/lib/mysql /var/lib/mysql-5.6-backup
sudo apt-get autoremove
sudo apt-get autoclean
进而
sudo apt-get install mysql-client-5.6
sudo apt-get update
警告:
- Ubuntu 从 16.04 开始切换到 systemd。使用 mysql 5.6 时可能也需要使用 upstart 启动 16.04。
答案2
我添加了 Ubuntu 14.04 存储库(在 Ubuntu 18.04 中):
sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu trusty universe'
我可以安装:
sudo apt install mysql-client-5.6