Ubuntu系统安装MySQL服务端及使用root账号远程登录

使用sudo apt install mysql-server命令在线安装MySQL服务端

LTXIT-20250620160951

为MySQL默认限制了root用户的远程登录,我们要编辑MySQL配置文件/etc/mysql/mysql.conf.d/mysqld.cnf),将【bind-addres127.0.0.1】和【mysqlx-bind-address = 127.0.0.1】修改为【bind-address = 0.0.0.0和【mysqlx-bind-address = 0.0.0.0】或直接将这两行注释掉。

LTXIT-20250620161746

使systemctl daemon-reload

systemctl daemon-reload

使sudo systemctl restart mysqlMySQL

sudo systemctl restart mysql

是在本地登录MySQL,然后访root

CREATE USER 'root'@'%' IDENTIFIED BY 'set_password';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;

使rootMySQL

posted @ 2026-03-29 15:51  L_Monkey  阅读(6)  评论(0)    收藏  举报