feat: upgdb.sh fix
This commit is contained in:
@@ -6,13 +6,17 @@ mysql_sql_dir=${docker_work_dir}/mysql/db
|
|||||||
docker_sql_dir=/docker-entrypoint-initdb.d
|
docker_sql_dir=/docker-entrypoint-initdb.d
|
||||||
docker_mysql_conf_d=/etc/mysql/conf.d
|
docker_mysql_conf_d=/etc/mysql/conf.d
|
||||||
docker_my_conf_file=${docker_mysql_conf_d}/my.cnf
|
docker_my_conf_file=${docker_mysql_conf_d}/my.cnf
|
||||||
mysql_ocker_name=wfc-mysql
|
mysql_container_name=wfc-mysql
|
||||||
|
|
||||||
|
# 获取 MySQL 容器的 IP 地址
|
||||||
|
mysql_container_ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${mysql_container_name})
|
||||||
# 在容器内生成 my.cnf 文件
|
# 在容器内生成 my.cnf 文件
|
||||||
docker exec ${mysql_ocker_name} bash -c "cat <<EOF > ${docker_my_conf_file}
|
docker exec ${mysql_container_name} bash -c "cat <<EOF > ${docker_my_conf_file}
|
||||||
[client]
|
[client]
|
||||||
user=root
|
user=root
|
||||||
password=\${MYSQL_ROOT_PASSWORD}
|
password=\${MYSQL_ROOT_PASSWORD}
|
||||||
|
host=${mysql_container_ip}
|
||||||
|
port=$
|
||||||
EOF"
|
EOF"
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@@ -22,8 +26,8 @@ case "$1" in
|
|||||||
for sql in ./upgrade/${db_name}/*.sql; do
|
for sql in ./upgrade/${db_name}/*.sql; do
|
||||||
if [ -f "$sql" ]; then
|
if [ -f "$sql" ]; then
|
||||||
echo -n "Execute SQL script: ${sql} ... "
|
echo -n "Execute SQL script: ${sql} ... "
|
||||||
# docker exec -i ${mysql_ocker_name} mysql -u ${db_name} < ${sql};
|
# docker exec -i ${mysql_container_name} mysql -u ${db_name} < ${sql};
|
||||||
docker exec -i ${mysql_ocker_name} mysql --defaults-extra-file=${docker_my_conf_file} ${db_name} < ${sql}
|
docker exec -i ${mysql_container_name} mysql --defaults-extra-file=${docker_my_conf_file} ${db_name} < ${sql}
|
||||||
if [ $? = 0 ]; then
|
if [ $? = 0 ]; then
|
||||||
echo "done"
|
echo "done"
|
||||||
fi
|
fi
|
||||||
@@ -38,7 +42,7 @@ case "$1" in
|
|||||||
for sql in ./upgrade/${db_name}/*.sql; do
|
for sql in ./upgrade/${db_name}/*.sql; do
|
||||||
if [ -f "$sql" ]; then
|
if [ -f "$sql" ]; then
|
||||||
echo -n "Execute SQL script: ${sql} ... "
|
echo -n "Execute SQL script: ${sql} ... "
|
||||||
docker exec -i ${mysql_ocker_name} mysql --defaults-extra-file=${docker_my_conf_file} ${db_name} < ${sql}
|
docker exec -i ${mysql_container_name} mysql --defaults-extra-file=${docker_my_conf_file} ${db_name} < ${sql}
|
||||||
if [ $? = 0 ]; then
|
if [ $? = 0 ]; then
|
||||||
echo "done"
|
echo "done"
|
||||||
fi
|
fi
|
||||||
@@ -53,7 +57,7 @@ case "$1" in
|
|||||||
for sql in ./upgrade/${db_name}/*.sql; do
|
for sql in ./upgrade/${db_name}/*.sql; do
|
||||||
if [ -f "$sql" ]; then
|
if [ -f "$sql" ]; then
|
||||||
echo -n "Execute SQL script: ${sql} ... "
|
echo -n "Execute SQL script: ${sql} ... "
|
||||||
docker exec -i ${mysql_ocker_name} mysql --defaults-extra-file=${docker_my_conf_file} ${db_name} < ${sql}
|
docker exec -i ${mysql_container_name} mysql --defaults-extra-file=${docker_my_conf_file} ${db_name} < ${sql}
|
||||||
if [ $? = 0 ]; then
|
if [ $? = 0 ]; then
|
||||||
echo "done"
|
echo "done"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user