ubuntu完全卸载mysql
可以先用 dpkg --list|grep mysql 查看自己的mysql有哪些依赖
一、先卸载 mysql-common
sudo apt-get remove mysql-common
二、然后再卸载
sudo apt-get autoremove --purge mysql-server-5.0
再用dpkg --list|grep mysql查看,还剩什么就卸载什么
三、最后清除残留数据
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
Ubuntu安装mysql
一、安装
1、更新软件库
sudo apt update
2、安装mysql服务
sudo apt install mysql-server
*这步就已经安装mysql-client。
3、 安装依赖
sudo apt install libmysqlclient-dev
二、 检查状态
sudo netstat -tap | grep mysql
如果出现“无此命令”,输入命令sudo apt install netstat
三、设置root密码
1、进入root状态
$ sudo su
2、进入mysql
# mysql
3、配置数据库root权限
update mysql.user set authentication_string=PASSWORD(‘123456’), plugin=‘mysql_native_password’ where user=‘root’;
4、设置生效和退出mysql、root模式
flush privileges; exit;
5、重启MySQL服务
$ sudo /etc/init.d/mysql restart
6、重新进入MySQL
$ mysql -u root -p
参考:
https://www.cnblogs.com/darklights/p/9910439.html
https://www.cnblogs.com/darklights/p/9910513.html