当我在Dockerfile的末尾使用CMD [ "./myscript.sh" ]
执行mysqld
时,我无法启动mysql守护程序。但是CMD [ "mysqld" ]
可以正常工作。
Dockerfile
FROM mysql:5.7
USER mysql
COPY ./setconf.sh .
COPY config/my.cnf /etc/mysql/conf.d
CMD [ "./setconf.sh" ]
# CMD ["mysqld"]
# This command works !
我正在遇到这个错误:
[ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it
[ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
docker-compose.yml
mysql:
build: mysql
environment:
MYSQL_PASSWORD: pass
MYSQL_ROOT_PASSWORD: pass
HOST: mysql
MYSQL_ROOT_HOST: mysql
ports:
- "3306:3306"
./setconf.sh
mysqld
注意:
- 每次尝试都要运行
docker-compose down
- 我需要特殊的选项来运行mysql
my.cnf
[mysqld]
default-storage-engine = INNODB
sql-mode = "STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
transaction-isolation = READ-COMMITTED
innodb_flush_log_at_trx_commit = 1
init_connect = "set session autocommit=0"
log_bin_trust_function_creators = 1
max_sp_recursion_depth = 100
lower_case_table_names = 1
thread_stack = 256K
max_allowed_packet = 16M
。