删除之前安装的

sudo apt-get remove --purge *mysql*
sudo rm -rf /etc/mysql /var/lib/mysql
sudo apt-get remove --purge *mariadb*

然后

sudo apt update
sudo apt upgrade

然后

sudo apt install mysql-server

安装完成之后

sudo service mysql start

如果无法启动

cat /var/log/mysql/error.log

查看错误日志发现,端口被占用,所以无法启动,查找发现,wsl 的ubuntu 和 windows 是公用端口的,所以使用命令

netstat -ano| findstr 3306
在windwos下查看并且记下pid (最后一列),打开任务管理器,打开详细信息,关闭那个pid
 
 
 
 
 
 
 
 

 然后重新 启动mysql ,成功。

 

 设置新密码

>use mysql;
>select host,user,plugin,authentication_string from user;  #root用户的plugin为auth_socket,密码为空
>update user set plugin="mysql_native_password",authentication_string=password('新密码') where user="root";

刷新权限

flush privileges;

重新登入

 

wsl,Ubuntu,关于解决E: Could not read response to hello message from hook [ ! -f /usr/bin/snap ] || /usr/

解决方法:

sudo rm -rf /etc/apt/apt.conf.d/20snapd.conf

 

相关文章:

  • 2021-06-12
  • 2021-11-02
  • 2022-02-01
  • 2021-10-31
  • 2021-07-23
  • 2022-12-23
  • 2021-06-06
  • 2021-04-26
猜你喜欢
  • 2021-10-27
  • 2021-11-24
  • 2022-12-23
  • 2021-09-13
  • 2021-07-03
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案