Mysql docker赢得';t为用户授予权限

Mysql docker赢得';t为用户授予权限,mysql,docker,Mysql,Docker,我正在从这样的dockerfile创建Mysql docker容器: FROM mysql:5.7 MAINTAINER developer # The official MySQL docker image will run all .sh and .sql scripts found in this directory # the first time the container is started. COPY init.sql /docker-entrypoint-initdb.d

我正在从这样的dockerfile创建Mysql docker容器:

FROM mysql:5.7

MAINTAINER developer

# The official MySQL docker image will run all .sh and .sql scripts found in this directory
# the first time the container is started.
COPY init.sql /docker-entrypoint-initdb.d
COPY my.cnf /etc/mysql/conf.d
init.sql

CREATE DATABASE IF NOT EXISTS rtb;
CREATE DATABASE IF NOT EXISTS rtb_test;
CREATE USER 'rtb'@'%' IDENTIFIED BY 'secret';
GRANT ALL PRIVILEGES ON rtb.* TO 'rtb'@'%' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON rtb_test.* TO 'rtb'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
my.cnf

[mysqld]
# Always use UTC
default-time-zone='+00:00'

# To turn off strict mode (alas, we started out that way, will be work to turn it on)
sql-mode="NO_ENGINE_SUBSTITUTION"

max-allowed-packet = 16M

### Per-thread Buffers
sort-buffer-size = 2M
read-buffer-size = 128K
read-rnd-buffer-size = 256K
join-buffer-size = 256K

### Temp Tables
tmp-table-size = 64M
max-heap-table-size = 64M

#### Storage Engines
default-storage-engine = InnoDB
innodb = FORCE
这里的问题是,Mysql在创建容器时并没有授予rtb_测试数据库的权限,而是为rtb用户授予数据库rtb的权限。。。但语法是正确的,我可以由root用户从容器内部手动运行该代码,并为用户rtb授予权限

我有另一个项目,它具有相同的
init.sql
文件(只是另一个数据库/用户名),并且所有项目都正常工作


你知道这里怎么了吗?谢谢

这是不是通配符?尽管看起来它无论如何都应该与通配符匹配,但要在
\uu
上以db名称完全匹配,您需要将其转义为:
在'rtb\\u test`.*上转义为
。嗯,我不确定通配符,但正如我提到的,我在另一个项目中使用了相同的代码,在数据库名称中也有
\uu
,并且它在那里工作。。。但不管怎样,我还是要设法逃脱