1.环境文件
-bash-4.1$ more mysql_env.ini #!/bin/sh #set env MYSQL_USER=root MYSQL_PASS=123456‘ #check parameter if [ $# -ne 1 ] then HOST_PORT=3306 else HOST_PORT=$1 fi -bash-4.1$
2.创建启动脚本
-bash-4.1$ more mysql_db_startup.sh #!/bin/sh source /opt/mysql/scripts/mysql_env.ini echo "Startup MySQL Service:localhost_"${HOST_PORT} /opt/mysql/bin/mysqld_safe --defaults-file=/opt/mysql/my.cnf & -bash-4.1$
3.创建关闭脚本
-bash-4.1$ more mysql_db_shutdown.sh #!/bin/sh source /opt/mysql/scripts/mysql_env.ini echo "Shutdown MySQL Service:localhost_"${HOST_PORT} /opt/mysql/bin/mysqladmin --defaults-file=/opt/mysql/my.cnf -u${MYSQL_USER} -p${MYSQL_PASS} -hlocalhost shutdown -bash-4.1$
4.创建快速登陆脚本
-bash-4.1$ more mysqlplus.sh #!/bin/sh source /opt/mysql/scripts/mysql_env.ini echo "Login MySQL Service:localhost_"${HOST_PORT} /opt/mysql/bin/mysql --defaults-file=/opt/mysql/my.cnf -u${MYSQL_USER} -p${MYSQL_PASS} -h localhost -bash-4.1$
5.将上述脚本目录 加入PATH环境变量
echo "export PATH=/opt/mysql/scripts/:\$PATH" >> ~/.bash_profile
source ~/.bash_profile
时间: 2024-10-07 19:40:00