【发布时间】:2021-04-06 15:11:01
【问题描述】:
此问题与位于Dbdeployer at Github 的第 3 方工具 dbdeployer 相关
有问题的部分:
用户:
root,默认授权由正在安装的服务器版本给出。
我分别在port 5730 and port 5731 上安装了一个实例。 (对应 MySQL 5.7.30 和 5.7.31)。
我可以这样连接:
mysql -u msandbox -p -h 127.0.0.1 -P 5730
mysql -u msandbox -p -h 127.0.0.1 -P 5731
mysql -u mycustomusername -p -h 127.0.0.1 -P 5730
我为文章中所示的赠款创建了一个文件:
使用选项
--post-grants-sql-file加载指令。
> cat << EOF > orchestrator.sql
CREATE DATABASE IF NOT EXISTS orchestrator;
CREATE USER orchestrator IDENTIFIED BY 'msandbox';
GRANT ALL PRIVILEGES ON orchestrator.* TO orchestrator;
GRANT SELECT ON mysql.slave_master_info TO orchestrator;
EOF
$ dbdeployer deploy single 5.7 \
--post-grants-sql-file=$PWD/orchestrator.sql
这适用于由 SQL 脚本(及其授权)部署的新空数据库,但我现在有一个 现有 实例,并希望从 创建一个新数据库>在 mysql 实例中。
文章声称root应该可用,但是:
mysql -u root -p -h 127.0.0.1 -P 5731
Access denied for user 'root'@'localhost' (using password: YES)
我在 3306 上安装了本地实例,但这不应该是我需要登录的用户。
当我这样做时:
mysql -u root -p -h localhost -P 5731
我可以登录,_但是这似乎忽略了端口(当连接为 localhost 时),因为我看到 不同的数据库(那些在端口 3306 上而不是来自 5730/5731 的那些)!
这也证实了我对端口被忽略的怀疑:
SHOW GRANTS FOR mycustomusername;
ERROR 1141 (42000): There is no such grant defined for user 'mycustomusername' on host '%'
SHOW GLOBAL VARIABLES LIKE '%port%';
.... truncated ....
port | 3306
我需要使用root@host5731 和root@host5730,但这里似乎没有使用root 的方法?
我需要执行以下一项(其中一项):
- 在这些端口使用
root用户, - 想办法让
msandbox或mycustomusername能够在新数据库上执行GRANT ALL PRIVILEGES。
为什么?
当我已经拥有现有数据库时,我无法删除/重新创建新的 MySQL 实例来添加新数据库(使用 SQL 文件方法)--post-grants-sql-file。
【问题讨论】:
标签: mysql database port dbdeploy