This commit is contained in:
2023-04-16 21:38:32 +08:00
parent a0849e40ef
commit 0b6c876a0f
59 changed files with 1026 additions and 189 deletions

View File

@@ -41,9 +41,9 @@ function Quit {
function Init {
rm -f $SOCK_FILE $PID_FILE
chown -R mysql.mysql $LOG_DIR $BINLOG_DIR $DATA_DIR
chown -R mysql:mysql $LOG_DIR $BINLOG_DIR $DATA_DIR
if [ ! -d "$DATA_DIR/mysql" ]; then
Print Init mysql db files ...
Print Initing mysql db files ...
mysql_install_db --user=mysql > /dev/null
INIT_FLAG=1
fi
@@ -52,7 +52,7 @@ function Init {
function StartProc {
local sql_file=
local sql_files=
Print Start mysql ...
Print Starting mysql ...
mysqld -u mysql &
PIDS="$PIDS $!"
while sleep 1; do
@@ -61,12 +61,12 @@ function StartProc {
done
echo
if [ -n "$INIT_FLAG" ]; then
Print Secure database ...
Print Securing database ...
mysql_secure_installation <<< "$(echo -e '\nn\nn\n\n\n\n\n')" > /dev/null
mysql -e "CREATE USER docker@localhost IDENTIFIED BY 'China_19\$(10)!'"
mysql -e "GRANT SHUTDOWN ON *.* TO docker@localhost"
if sql_files="$(ls $DATA_DIR/init_sql/*.sql 2>/dev/null)"; then
Print Import the sql files ...
Print Importing the sql files ...
for sql_file in $sql_files; do
Print Importing $sql_file ...
mysql < $sql_file

View File

@@ -26,6 +26,6 @@ password = China_19$(10)!\n\
' > /etc/mysql/my.cnf \
&& sed -i 's/stty/#stty/' /usr/bin/mysql_secure_installation \
&& mkdir -p /var/log/mysql /var/lib/mysql-bin /run/mysqld \
&& chown -R mysql.mysql /var/log/mysql /var/lib/mysql-bin /run/mysqld
&& chown -R mysql:mysql /var/log/mysql /var/lib/mysql-bin /run/mysqld
CMD ["/opt/ccmd"]