1.下载并解压mysql(版本号为:8.0.32)

1
sudo apt install -y mysql-server mysql-client libmysqlclient-dev

image-20250319111102924

  1. 查看密码
1
sudo cat /etc/mysql/debian.cnf

image-20250319111117223

3.以上述账号和密码登录mysql 

1
mysql -u debian-sys-maint -p2l938pIxxWJScIhB

image-20250319111220596

4.设置root账户密码(密码以123456为例)

1
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';

image-20250319111202375

 5.使用root用户登录mysql

1
mysql -u root -p123456

image-20250319111154964

 登录成功~