首先确认之前没安装过mysql,安装了可以卸载 sudo apt remove mysql-server
安装
sudo apt install mysql-server
进入mysql 第一次会有这个报错
➜ ~ mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
需要查看
vim /etc/mysql/debian.cnf
使用这里的帐号密码登录
mysql -u debian-sys-maint -p
这里进到mysql后需要改下root用户的密码
mysql新版不叫password了 需要更新authentication_string
update MySQL.user set authentication_string='' where user='root' ;
退出重启mysql
systemctl restart mysql
这时就可以了