1.执行命令安装mysql
sudo apt-get install mysql-server
sudo apt install mysql-client
2.查看初始账号和密码
sudo vim /etc/mysql/debian.cnf
3.用初始账号和密码登陆mysql,并查看databases;
mysql -u debian-sys-maint -p
K6LLXogASDI9UYCX
show databases;
4.使用mysql数据库
use mysql;
5.设置新的账号和密码
update user set authentication_string=PASSWORD('root') where user='root';
update user set plugin="mysql_native_password";
flush privileges;
6.重启mysql服务
/etc/init.d/mysql restart
7.用新账号和密码重新登陆mysql
mysql -u root -p
root
登陆成功~