我们正在将 MaxScale 实现为我们的应用程序和托管在 AWS Aurora MySQL 中的数据库之间的数据库代理。
我已经配置了 MaxScale 并验证所有服务器都可以连接,并且当我通过 cli 从应用服务器连接到代理端点时,一切正常:
mysql -h proxy.end.point -u admin -p
一切按预期顺利运行,并打开了连接。我可以use db_name;
毫无问题地调用和更改数据库,例如:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 76
Server version: 8.0.32 Source distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]> use db_name;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MySQL [db_name]>
然而,非常奇怪的是,当我将其指定db_name
为 cli 参数时,出现权限错误:
mysql -h proxy.end.point -u admin -p db_name
ERROR 1044 (42000): Access denied for user 'admin'@'ip.of.data.base' to database 'db_name'
我不确定这是否是 mysqladmin
用户的问题,或者是否是 MaxScale 的一些细微差别,但我很好奇是否有人有任何见解。
作为参考,我使用maxscale
用户作为代理用户,其具有以下权限:
GRANT SHOW DATABASES ON *.* TO `maxscale`@`%`
GRANT SELECT ON `mysql`.* TO `maxscale`@`%`
GRANT SELECT ON `mysql`.`columns_priv` TO `maxscale`@`%`
GRANT SELECT ON `mysql`.`db` TO `maxscale`@`%`
GRANT SELECT ON `mysql`.`procs_priv` TO `maxscale`@`%`
GRANT SELECT ON `mysql`.`proxies_priv` TO `maxscale`@`%`
GRANT SELECT ON `mysql`.`tables_priv` TO `maxscale`@`%`
GRANT SELECT ON `mysql`.`user` TO `maxscale`@`%`
以下是我的文件的内容/etc/maxscale.cnf
:
[maxscale]
threads=auto
debug=enable-statement-logging
[db_writer]
type=server
address=rds-writer-endpoint.rds.amazonaws.com
port=3306
[db_reader]
type=server
address=rds-reader-endpoint.rds.amazonaws.com
port=3306
[Read-Write-Service]
type=service
router=readwritesplit
servers=db_writer,db_reader
user=maxscale
password=maxscale_password
[Read-Write-Listener]
type=listener
service=Read-Write-Service
protocol=MariaDBClient
port=3306
我已经安装了 maxscale 版本24.02.4
。
任何帮助都非常感谢。谢谢!
因此,经过一些彻底的调试后,问题似乎出在用户名上。
每当我使用用户名连接时,
admin
我都会收到权限错误,但我创建了一个具有相同权限的新用户并且能够成功连接。因此,MaxScale 和用户名连接的某种组合
admin
导致了该问题。解决方法是创建具有相同权限的用户并与其连接。