系统环境
- 操作系统:Ubuntu Server 22.04
- MySQL 版本:8.0.30-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu))
修改 my.cnf 配置文件
$ sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
修改 bind-address
# If MySQL is running as a replication slave, this should be
# changed. Ref https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_tmpdir
# tmpdir = /tmp
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 0.0.0.0
mysqlx-bind-address = 127.0.0.1
修改权限
$ mysql -u root -p
mysql>GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'%' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
mysql>FLUSH PRIVILEGES;