From 16eb9c0e3157d10dcd54ae303e5c8a4526f5ca47 Mon Sep 17 00:00:00 2001 From: 15892072232 <3094677748@qq.com> Date: Thu, 30 Oct 2025 10:36:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E8=AE=BA=E6=96=87?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=EF=BC=88=E9=83=91=E7=91=9C=E7=94=9C=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- remote_mysql_access.sql | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 remote_mysql_access.sql diff --git a/remote_mysql_access.sql b/remote_mysql_access.sql new file mode 100644 index 000000000..701533b56 --- /dev/null +++ b/remote_mysql_access.sql @@ -0,0 +1,20 @@ +-- 为root用户添加远程连接权限 +USE mysql; + +-- 查看当前用户权限 +SELECT user, host FROM user; + +-- 创建远程访问用户(建议使用专用用户而非root) +CREATE USER IF NOT EXISTS 'remote_user'@'%' IDENTIFIED BY '123456'; + +-- 授予远程用户访问权限 +GRANT ALL PRIVILEGES ON ry_vue.* TO 'remote_user'@'%' WITH GRANT OPTION; + +-- 如果需要让root用户也能远程访问(不推荐) +-- GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION; + +-- 刷新权限 +FLUSH PRIVILEGES; + +-- 显示授权结果 +SHOW GRANTS FOR 'remote_user'@'%'; \ No newline at end of file