MySQL:Ubuntu18.04 如何安装和卸载mysql8.0.16

1、下载mysql-apt-config_0.8.13-1_all.deb

MySQL:Ubuntu18.04 如何安装和卸载mysql8.0.16_第1张图片

 2、 运行命令

sudo dpkg -i mysql-apt-config_0.8.13-1_all.deb
sudo apt update

 3、安装MySQL

sudo apt install mysql-server

 4、查看mysql

mysql -u root -p 

若执行报如下错误:

ERROR 1698 (28000): Access denied for user 'root'@'localhost'

 则可以通过如下方式

sudo vi /etc/mysql/conf.d/mysql.cnf

 添加如下内容

[mysqld]
skip-grant-tables

重启MySQL

service mysql restart

再进行

mysql -u root -p

由于MySQL版本大于MySQL 8.0.11,不能使用如下方式修改密码了

use mysql;
update user set authentication_string=password('你的密码') where User='root';
flush privileges;

要使用如下方法:

use mysql;
update user set plugin = 'mysql_native_password', authentication_string=null where User='root';
flush privileges;

将前面配置的skip-grant-tables去掉

sudo vi /etc/mysql/conf.d/mysql.cnf

重启MySQL,再登录

service mysql restart
mysql -u root

再使用

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码';

退出后,就可以用新密码登录了。

 5、卸载mysql

sudo apt-get auto-remove  mysql-server

另外,还要把/var/lib/mysql和/etc/mysql目录删除

 

参考文档

Ubuntu18.04 安装mysql8.0.11
mysql出现ERROR1698(28000):Access denied for user root@localhost错误解决方法
How to reset the root password in MySQL 8.0.11?
Can't start MySQL5.5 on Ubuntu 12.04 - “dpkg: dependency problems”

 

 

 

 

你可能感兴趣的:(MySQL)