我尝试从远程服务器(Linux)连接到我的本地 MySQL 数据库(在我的 Mac 上)以存储我的超参数优化试验:
connection = mysql.connector.connect(
host='ip_adress',
database='exampl_db',
port='3306',
user='user',
password='password',
)
cursor = connection.cursor()
cursor.execute('CREATE DATABASE IF NOT EXISTS example_db')
study = optuna.create_study(
pruner=optuna.pruners.MedianPruner(n_warmup_steps=20),
study_name='test_study',
storage='mysql://password:user@ip_adress/example_db',
load_if_exists=True,
direction='minimize')
但得到这个错误按摩
_mysql_connector.MySQLInterfaceError: Can't connect to MySQL server on 'vnp_ip:3306' (111)
我将绑定地址更改为 0.0.0.0 (在我的 my.cnf 文件中)
并授予对 mysql 中远程用户的访问权限
grant all on *.* to 'user'@'%';
我是这个话题的新手,不知道我的方式。非常感谢帮助