首先删除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

运行它。

error:当时状态属于inactive(dead),然后我运行,结果报错:

 Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

解决:

[root@izx5uaa5mz0yf0z ~]# ls -ld /var/run/mysqld/
drwxr-xr-x mysql mysql 1月 : /var/run/mysqld/
[root@izx5uaa5mz0yf0z ~]# mkdir -p /var/run/mysqld
[root@izx5uaa5mz0yf0z ~]# ls -ld /var/run/mysqld/
drwxr-xr-x mysql mysql 1月 : /var/run/mysqld/
[root@izx5uaa5mz0yf0z ~]#sudo chown mysql.mysql /var/run/mysqld/
[root@izx5uaa5mz0yf0z ~]# sudo /etc/init.d/mysql start
[ ok ] Starting mysql (via systemctl): mysql.service.

成功:

ubuntu16.04彻底卸载mysql并且重新安装mysql的更多相关文章

  1. centos下删除MYSQL 和重新安装MYSQL

    centos下彻底删除MYSQL 和重新安装MYSQL 因centos系统自带的mysql版本比较低5.1,所以想卸载重新安装较新版本,下面是过程 1 删除Mysql yum remove mysql ...

  2. Ubuntu16.04彻底卸载MySQL

    删除mysql的数据文件 sudo rm /var/lib/mysql/ -R 删除mysql的配置文件 sudo rm /etc/mysql/ -R 自动卸载mysql(包括server和clien ...

  3. ubuntu16.04 彻底卸载MySQL

    以MySQL- 5.7.18为例: sudo apt-get autoremove --purge mysql-server-5.7 #sudo apt-get remove mysql-server ...

  4. centos下彻底删除MYSQL 和重新安装MYSQL

    在Centos6.3上装了一个Mysql,结果mysql库被我玩丢了(这里面管理了mysql的权限).现在采用先彻底删除,然后重新安装Mysql. 1 删除Mysql yum remove  mysq ...

  5. ubuntu16.04安装LNMP(ubuntu+Nginx+mysql+PHP7.0)

    系统环境: Ubuntu 16.04.2 LTS nginx version: nginx/1.10.3 (Ubuntu) PHP 7.0.22-0ubuntu0.16.04.1 mysql  Ver ...

  6. ubuntu16.04 下 卸载CUDA9.1

    网上很多教程删除都全  安装其他还会出错 在这把它删除,在命令行中输入 sudo apt-get remove cuda sudo apt-get autoclean sudo apt-get rem ...

  7. [Linux]ubuntu16.04 nginx彻底删除与重新安装

    nginx彻底删除与重新安装 查看nginx正在运行的进程,如果有就kill掉 sudo netstat -ntlp | grep nginx sudo kill -9 进程id 删除nginx,pu ...

  8. Ubuntu16.04重新安装MySQL数据库

    安装之前先检查mysql是否卸载干净 dpkg --list|grep mysql 如果没有卸载干净请看上篇文章将mysql卸载干净 Ubuntu16.04彻底卸载MySQL 开始安装 可以直接默认安 ...

  9. ubuntu16.04与mysql的运维注意事项

    1:环境 ubuntu16.04 虚拟机,需要搭建一个MySQL的生产或者测试环境 2:操作步骤 2.1:更新系统源 首次给root用户指定密码  ,先用安装用户登录 sudo  apt-get up ...

随机推荐

  1. 如何修改wordpress的.po和.mo配置文件

    如果我们在定制个性化WP模版时,若要修改默认语言包中文字描述,则可以通过修改zh_CN.mo和zh_CN.po来实现,但mo文件是不能直接修改编辑,因此就只能修改po文件了,po文件不能通过我们常用的 ...

  2. AC日记——[HNOI2008]GT考试 bzoj 1009

    1009 思路: KMP上走DP(矩阵加速): DP[i][j]表示当前在第i位,同是匹配到不吉利串的第j位的方案数: 代码: #include <bits/stdc++.h> using ...

  3. AC日记——国王游戏 洛谷 P1080

    国王游戏 思路: 贪心+高精: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 1005 struct Dat ...

  4. 四十六 常用内建模块 itertools

    Python的内建模块itertools提供了非常有用的用于操作迭代对象的函数. 首先,我们看看itertools提供的几个“无限”迭代器: >>> import itertools ...

  5. 一款你不容错过的Laravel后台管理扩展包 —— Voyager

    http://laravelacademy.org/post/6401.html  Posted on 2016年11月1日 by  学院君 1.简介 Voyager是一个你不容错过的Laravel后 ...

  6. linux在命令执行过程中ctrl +z 后[1]+ Stopped

    进程挂起 stopped 代表有进程挂起 [1]是id号 可以通过Linux命令:jobs 查看挂起进程 fg 1 把任务1放到前台 bg 1 把任务1放到后台

  7. caffe-安装anaconda后重新编译caffe报错

    ks@ks-go:~/caffe-master$ make -j16 CXX/LD -o .build_release/tools/convert_imageset.bin CXX/LD -o .bu ...

  8. VS2013下实现移动端的跨平台开发

    http://www.th7.cn/Program/Android/201412/336394.shtml 前一天准备下载VS2015预览版,到VisualStudio官网一看,发现微软发布了Visu ...

  9. [lampp] 不能通过互联网连接数据库 MySQL is not accessable via network

    LAMPP安装目录下的/etc/my.cnf文件注释掉skip-networking #skip-networking#skip-networking

  10. POJ 1655.Balancing Act-树的重心(DFS) 模板(vector存图)

    Balancing Act Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 17497   Accepted: 7398 De ...