我正在从Dockerfile在OpenShift上部署MySQL。一切顺利,我可以使用oc rsh
初始化和填充数据库。但现在,我想自动化Dockerfile中的所有手动步骤。
mysql -u root
CREATE USER 'loyal'@'172.%' IDENTIFIED BY 'Test123';
GRANT ALL PRIVILEGES ON *.* TO 'loyal'@'172.%';
CREATE USER 'loy'@'localhost' IDENTIFIED BY 'Test123';
GRANT ALL PRIVILEGES ON *.* TO 'loyal'@'localhost';
flush privileges;
exit;exit;
mysql -u loyal -p loyal < main.sql
mysql -u loyal -p loyal
select * from BARCODE;
## I get a dump of data
FROM registry.access.redhat.com/rhscl/mysql-57-rhel7
ENV MYSQL_USER=loyal
ENV MYSQL_PASSWORD=loyal
ENV MYSQL_DATABASE=loyal
ENV MYSQL_ROOT_PASSWORD=loyal
COPY ./APP.sql /opt/app-root/src
COPY ./BARCODE.sql /opt/app-root/src
COPY ./CARD.sql /opt/app-root/src
COPY ./main.sql /opt/app-root/src
ADD users.sql /docker-entrypoint-initdb.d
我正在上面最后一行中的users.sql进行测试,因为我在Google上搜索了一个文件夹,其中配置在容器中被拾取但是我没有这样做。任何帮助将不胜感激!
mysql -u root
CREATE USER 'loyal'@'172.%' IDENTIFIED BY 'Test123';
GRANT ALL PRIVILEGES ON *.* TO 'loyal'@'172.%';
CREATE USER 'loyal'@'localhost' IDENTIFIED BY 'Test123';
GRANT ALL PRIVILEGES ON *.* TO 'loyal'@'localhost';
flush privileges;