ubuntu系统下安装配置MySQL 8.0.37-0ubuntu0.22.04.3服务
- 安装mysql
sudo apt update
sudo apt install mysql-server
sudo systemctl status mysql
- 进入mysql,创建特定用户,专门用于登录
sudo mysql;
create user 'user_name'@'ip_address' identified by "password";
grant all ON database_name.* to user_name@'ip_address' with grant option;
- 修改mysql的配置文件(/etc/mysql/mysql.conf.d/mysqld.cnf)
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
将bind-address = 0.0.0.0,并保存退出
- 重启mysql服务
sudo systemctl restart mysql
- 如果ufw是活跃状态的话,得开启3306端口,如果不是活跃状态就可以跳过了
sudo ufw allow 3306/tcp
- 如果云服务器的话记得在安全组中放行3306端口
- 客户端测试连接MySQL服务器
参考文献
https://www.myfreax.com/how-to-install-mysql-on-ubuntu-22-04/