or_enable="module_log"
innodb_monitor_enable="module_lock"
innodb_monitor_enable="module_buffer"
innodb_monitor_enable="module_index"
innodb_monitor_enable="module_ibuf_system"
innodb_monitor_enable="module_buffer_page"
innodb_monitor_enable="module_adaptive_hash"
[mysqldump]
quick
max_allowed_packet = 32M
9.初始化数据库
mkdir -pv /data/{mysql3306/{data,logs,tmp},conf,scripts,dumpdir}
/usr/local/mysql/bin/mysqld --defaults-file=/data/conf/my3306.cnf --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql3306/data
10.配置启动脚本
#!/bin/sh
port="3306"
my_lp="3306_system"
mysql_bin="/usr/local/mysql/bin/"
mysql_sock="/data/mysql${port}/data/mysql.sock"
config_file="/data/conf/my3306.cnf"
#start Mysql Services
function_start_mysql()
{
if [ ! -e "$mysql_sock" ];then
printf "Starting MySQL_3306 ...\n"
/bin/sh ${mysql_bin}/mysqld_safe --defaults-file=${config_file} 2>&1 > /dev/null &
else
printf "MySQL_3306 is running...\n"
exit
fi
}
#stop Mysql Services
function_stop_mysql()
{
if [ ! -e "$mysql_sock" ];then
printf "MySQL_3306 is stopped...\n"
exit
else
printf "Stoping MySQL_3306...\n"
${mysql_bin}/mysqladmin --login-path=${my_lp} -S ${mysql_sock} shutdown
fi
}
#restart Mysql Services
function_restart_mysql()
{
printf "Restarting MySQL_3306...\n"
function_stop_mysql
sleep 2
function_start_mysql
}
case $1 in
start)
function_start_mysql
;;
stop)
function_stop_mysql
;;
restart)
function_restart_mysql
;;
*)
printf "Usage: /data/scripts/mysql3306 {start|stop|restart}\n"
esac
chmod a+x /data/scripts/mysql3306
11.启动服务
/data/scripts/mysql3306 start
12.修改密码
mysql -uroot -p -S /data/mysql3306/data/mysql.sock
alter user user() identified by "netdata";
13.设置login-path
mysql_config_editor set --login-path=3306_root -uroot -p -S /data/mysql3306/data/mysql.sock
14.设置环境变量
echo "alias mysql3306='mysql --login-path=3306_root --defaults-file=/data/conf/my3306.cnf --default-character-set=utf8mb4'
">>~/.bashrc
source ~/.bashrc