Mysql docker不会为用户授予权限

时间:2018-03-05 19:53:11

标签: 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
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_test数据库的权限,但是为rtb用户授予数据库rtb的权限......但是语法是正确的,我可以从容器内部手动运行该代码用户和它授予用户rtb

的权限

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

知道这里有什么问题吗?感谢!!!

0 个答案:

没有答案