Ubuntu安装MySQL并配置远程访问
xgcd Lv3

安装MySQL

https://developer.aliyun.com/article/758177

MySQL操作

创建数据库

CREATE DATABASE IF NOT EXISTS 数据库名 DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

创建用户

CREATE USER ‘用户名‘@’%’ IDENTIFIED BY ‘用户密码’;

授权

GRANT all privileges ON . TO ‘用户名‘@’%’;

刷新系统权限表

flush privileges;

修改3306端口为任意IP访问

root用户修改配置

vim /etc/mysql/mysql.conf.d/mysqld.cnf
注释掉以下这行:
bind-address = 127.0.0.1

重启MySQL

/etc/init.d/mysql restart

查看防火墙状态,开放指定端口

https://blog.csdn.net/qq_36938617/article/details/95234909
https://blog.csdn.net/lianghecai52171314/article/details/113813826

查看端口开放状态: sudo ufw status

Status: active

To Action From


22 ALLOW Anywhere
3306 ALLOW Anywhere
22 (v6) ALLOW Anywhere (v6)
3306 (v6) ALLOW Anywhere (v6)

端口在线检测验证(前提: 腾讯云安全组放开MySQL3306端口)

https://coding.tools/cn/port-checker

远程访问MySQL

连接信息

jdbc:mysql://IP:3306/数据库名
用户名
用户密码

 Comments
Comment plugin failed to load
Loading comment plugin