1Panel icon indicating copy to clipboard operation
1Panel copied to clipboard

[Bug] Unable to Re-enable Remote Access for MySQL Database After Closing Settings

Open hhhguany opened this issue 1 year ago • 5 comments

Contact Information

No response

1Panel Version

v1.10.29-lts

Problem Description

In the MySQL database remote connection settings, when I click "Remote Access," it shows a success message. However, after closing the settings page, I am unable to enable remote access again. Every time I re-enter the settings, the remote access option remains disabled. Please fix this issue to ensure that the setting is properly saved and remote access can be enabled again.

Steps to Reproduce

Image

The expected correct result

No response

Related log output


Additional Information

No response

hhhguany avatar Apr 21 '25 10:04 hhhguany

提供一下你使用的 MySQL 版本,我们在本地尝试复现一下这个问题。

wanghe-fit2cloud avatar Apr 21 '25 10:04 wanghe-fit2cloud

以下商店里面安装的 MySQL 数据库均有此问题: mysql 8.4.5 mysql5 5.6.51 mariadb 11.6.2

hhhguany avatar Apr 24 '25 04:04 hhhguany

已复现,近期版本修复。

wanghe-fit2cloud avatar Apr 24 '25 04:04 wanghe-fit2cloud

dev 分支已经修复了 #8378 1Panel-dev/1Panel@600b7690833659342c761766f2877d4002b8b7a9

igophper avatar Apr 25 '25 01:04 igophper

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


The dev branch has been fixed

wanghe-fit2cloud avatar Apr 25 '25 01:04 wanghe-fit2cloud

有没有其他临时的修复方式?(不便升级到dev的方案)

2tof avatar May 13 '25 18:05 2tof

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Is there any other temporary fix? (Inconvenient to upgrade to dev)

wanghe-fit2cloud avatar May 13 '25 18:05 wanghe-fit2cloud

有没有其他临时的修复方式?(不便升级到dev的方案)

来源chatgpt,我解决了


✅ 一步步解决 Docker 中 MySQL 无法远程访问的问题


✅ 第一步:进入 MySQL 容器

先找到容器 ID 或名称:

docker ps

输出类似:

CONTAINER ID   IMAGE         COMMAND                  ...   NAMES
a1b2c3d4e5f6   mysql:8.0     "docker-entrypoint.s…"   ...   my-mysql

进入容器:

docker exec -it my-mysql bash

或者用容器 ID:

docker exec -it a1b2c3d4e5f6 bash

✅ 第二步:登录 MySQL 客户端

mysql -u root -p

输入你当初设置的 root 密码。


✅ 第三步:处理 root@'%' 权限问题

🧹 1. 先删除已有的 root@'%' 用户(如果有冲突):

DROP USER IF EXISTS 'root'@'%';

✅ 2. 重新创建远程 root 并授权:

CREATE USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '你的MySQL密码';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;

✅ 第四步:确认 MySQL 配置允许远程连接

在容器中修改 /etc/mysql/my.cnf/etc/mysql/mysql.conf.d/mysqld.cnf,找到并修改这一行:

bind-address = 0.0.0.0

如果找不到这一行,可以手动加到 [mysqld] 区块下:

[mysqld]
bind-address = 0.0.0.0

保存后,重启容器

exit
docker restart my-mysql

✅ 第五步:确认 Docker 暴露了 3306 端口

在你启动 MySQL 容器时,如果没有映射 3306 端口,你是连不上的。

可以检查一下是否带了类似:

-p 3306:3306

如果没带,建议你重新启动容器:

docker run -d \
  --name my-mysql \
  -e MYSQL_ROOT_PASSWORD=你的MySQL密码 \
  -p 3306:3306 \
  mysql:8.0

✅ 最后测试远程连接(外部主机):

mysql -u root -p -h <你的Docker主机IP> -P 3306

charon26 avatar Jun 05 '25 07:06 charon26

v1.10.30-lts 版本已发布。

wanghe-fit2cloud avatar Jun 10 '25 11:06 wanghe-fit2cloud