#!/bin/bash source <(curl -f -s --connect-timeout 10 --retry 3 https://dl.acepanel.net/public.sh) if [ $? -ne 0 ]; then echo "Download public.sh failed, please check the network or try again later." exit 1 fi name=${1} channel=${2} version=${3} mysql_path="${setup_path}/server/mysql" # 配置 mkdir ${mysql_path}/conf cat >${mysql_path}/conf/my.cnf </etc/systemd/system/mysqld.service </dev/null; then echo "MySQL service has started" break fi echo "Waiting for MySQL to start..." sleep 1 done if ! mysqladmin ping &>/dev/null; then error "MySQL startup timeout" fi root_password=$(cat /dev/urandom | head -n 16 | sha256sum | head -c 16) ${mysql_path}/bin/mysqladmin -u root password ${root_password} if [ "$?" != "0" ]; then error "Failed to initialize password" fi export MYSQL_PWD=${root_password} ${mysql_path}/bin/mysql -uroot -e "DROP DATABASE test;" ${mysql_path}/bin/mysql -uroot -e "DELETE FROM mysql.user WHERE user='';" ${mysql_path}/bin/mysql -uroot -e "FLUSH PRIVILEGES;" # 启用 RocksDB if [[ ${MEM} -ge 7900 && -f "${mysql_path}/lib/plugin/ha_rocksdb.so" ]]; then ${mysql_path}/bin/mysql -uroot -e "INSTALL PLUGIN ROCKSDB SONAME 'ha_rocksdb.so';" ${mysql_path}/bin/mysql -uroot -e "INSTALL PLUGIN ROCKSDB_CFSTATS SONAME 'ha_rocksdb.so';" ${mysql_path}/bin/mysql -uroot -e "INSTALL PLUGIN ROCKSDB_DBSTATS SONAME 'ha_rocksdb.so';" ${mysql_path}/bin/mysql -uroot -e "INSTALL PLUGIN ROCKSDB_PERF_CONTEXT SONAME 'ha_rocksdb.so';" ${mysql_path}/bin/mysql -uroot -e "INSTALL PLUGIN ROCKSDB_PERF_CONTEXT_GLOBAL SONAME 'ha_rocksdb.so';" ${mysql_path}/bin/mysql -uroot -e "INSTALL PLUGIN ROCKSDB_CF_OPTIONS SONAME 'ha_rocksdb.so';" ${mysql_path}/bin/mysql -uroot -e "INSTALL PLUGIN ROCKSDB_GLOBAL_INFO SONAME 'ha_rocksdb.so';" ${mysql_path}/bin/mysql -uroot -e "INSTALL PLUGIN ROCKSDB_COMPACTION_HISTORY SONAME 'ha_rocksdb.so';" ${mysql_path}/bin/mysql -uroot -e "INSTALL PLUGIN ROCKSDB_COMPACTION_STATS SONAME 'ha_rocksdb.so';" ${mysql_path}/bin/mysql -uroot -e "INSTALL PLUGIN ROCKSDB_ACTIVE_COMPACTION_STATS SONAME 'ha_rocksdb.so';" ${mysql_path}/bin/mysql -uroot -e "INSTALL PLUGIN ROCKSDB_DDL SONAME 'ha_rocksdb.so';" ${mysql_path}/bin/mysql -uroot -e "INSTALL PLUGIN ROCKSDB_INDEX_FILE_MAP SONAME 'ha_rocksdb.so';" ${mysql_path}/bin/mysql -uroot -e "INSTALL PLUGIN ROCKSDB_LOCKS SONAME 'ha_rocksdb.so';" ${mysql_path}/bin/mysql -uroot -e "INSTALL PLUGIN ROCKSDB_TRX SONAME 'ha_rocksdb.so';" ${mysql_path}/bin/mysql -uroot -e "INSTALL PLUGIN ROCKSDB_DEADLOCK SONAME 'ha_rocksdb.so';" fi unset MYSQL_PWD acepanel app write ${name} ${channel} ${version} acepanel setting write mysql_root_password ${root_password} acepanel database add-server --type=mysql --name=local_mysql --host=127.0.0.1 --port=3306 --username=root --password=${root_password}