ubuntu16.04彻底卸载mysql并且重新安装mysql

简介首先删除mysql: sudo apt-get remove mysql-* dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P 清理完毕: 复制代码 dpkg: error: --purge needs at least one package name argument Type dpkg --help for help about installing and deinstalling packages [*]; U
首先删除mysql:

sudo apt-get remove mysql-*
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
清理完毕:

复制代码
dpkg: error: --purge needs at least one package name argument

Type dpkg --help for help about installing and deinstalling packages [*];
Use 'apt' or 'aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;

Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !
复制代码
然后安装mysql.

可以直接默认安装:

sudo apt-get install mysql-client mysql-server
因为Ubuntu是16.04的,所以会默认安装5.7版本。

 

如果要安装5.6(因为5.7版本据说经常出错),按以下步骤:

复制代码
sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu trusty universe'  //增加旧的repo

sudo apt-get update  //更新源

sudo apt-cache search mysql | grep 5.6   //查看软件源里时候有mysql 5.6 可供安装

//查看结果
percona-server-server-5.6 - Percona Server database server binaries
percona-server-test-5.6 - Percona Server database test suite
percona-xtradb-cluster-server-5.6 - Percona XtraDB Cluster database server binaries
mysql-client-5.6 - MySQL database client binaries
mysql-client-core-5.6 - MySQL database core client binaries
mysql-common-5.6 - MySQL 5.6 specific common files, e.g. /etc/mysql/conf.d/my-5.6.cnf
mysql-server-5.6 - MySQL database server binaries and system database setup
mysql-server-core-5.6 - MySQL database server binaries
mysql-source-5.6 - MySQL source
mysql-testsuite-5.6 - MySQL 5.6 testsuite

sudo apt-get install mysql-server-5.6 mysql-client-5.6  //安装
复制代码
 安装完成后查看mysql状态:

sudo service mysql status
一般安装完成之后都是会自动运行的。
如果没有运行你可以

sudo service mysql start

运行它。


实测默认的 5.7 版本,重装后依然有问题,这时重装5.6

本文转自:https://www.cnblogs.com/xym4869/p/8781792.html
新加评论 评论标题:

文章评论

    ubuntu16.04卸载mysql5.7安装mysql5.6

        2020-04-27    
    修改 删除

    https://www.cnblogs.com/JThinking/p/9409146.html

    按步骤操作即可,最后一步会要求输入密码


    1. 删除mysql

    a. sudo apt-get autoremove --purge mysql-server-5.0
    b. sudo apt-get remove mysql-server
    c. sudo apt-get autoremove mysql-server
    d. sudo apt-get remove mysql-common (非常重要)
    2. 清理残留数据
    dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P

    如果报如下错误,证明你的系统中没有残留配置文件了,无须担心。

    dpkg: --purge needs at least one package name argument

    Type dpkg --help for help about installing and deinstalling packages [*];
    Use `dselect' or `aptitude' for user-friendly package management;
    Type dpkg -Dhelp for a list of dpkg debug flag values;
    Type dpkg --force-help for a list of forcing options;
    Type dpkg-deb --help for help about manipulating *.deb files;
    Type dpkg --license for copyright license and lack of warranty (GNU GPL) [*].

    Options marked [*] produce a lot of output - pipe it through `less' or `more' !
    下面安装mysql5.6
    你必须先删除这些文件夹:/etc/mysql/ /var/lib/mysql /var/log/mysql/var/lib/mysql-filters /var/lib/mysql-keyring和这个文件:/var/lib/mysql/debian-5.7.flag - T0m3kk 7月22日在12:41
    1. sudo apt-get install software-properties-common
    2. $ sudo add-apt-repository -y ppa:ondrej/mysql-5.6
    3. $ sudo apt-get update
    4. $ sudo apt-get install mysql-server-5.6
评论列表
ubuntu16.04卸载mysql5.7安装mysql5.6