sudo apt-get update sudo apt-get install mysql-server
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new_password'; FLUSH PRIVILEGES;
添加用户并赋予权限
CREATE USER 'remote_user'@'%' IDENTIFIED BY 'Password@123'; GRANT ALL PRIVILEGES ON *.* TO 'remote_user'@'%' WITH GRANT OPTION; FLUSH PRIVILEGES;
编辑配置文件
sudo nano /etc/mysql/my.cnf
修改 bind-address 配置项
[mysqld] bind-address = 0.0.0.0
重启mysql
sudo service mysql restart
配置防火墙
sudo ufw allow 3306/tcp
上一篇:深度刨析程序中的指针