一、命令安装mysql
apt install mysql-server
二、修改账号和密码
- 默认的root没有密码
```shell
vim /etc/mysql/debian.cnf # 查看用户信息
使用root进入后修改host信息```sqluse mysql;select User,Host from user; # 查看配置update user set Host ='%' where User = 'root'; # 修改localhost为%,能够让外面连接进来update user set authentication_string=password('qq1448265203') where user='root'; # 修改root用户的密码grant all privileges on *.* to 'root'@'%' identified WITH mysql_native_password BY by 'qq1448265203';MYSQL: //把系统的root修改密码 update mysql.user set authentication_string=password('qq1448265203') where user='root'; //能远程访问 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'qq1448265203'; update user set authentication_string=PASSWORD('qq1448265203') where user='root'; # 更改密码 grant all privileges on *.* to 'root'@'%' identified WITH mysql_native_password BY by 'qq1448265203'; ALTER USER 'root’@‘localhost' IDENTIFIED WITH mysql_native_password BY ‘你的密码’;
参考博客