标签:iad 远程连接mysql sage ssl ide default 数据 mod cti
mysql5.7 基于二进制编译多实例安装规划相关目录
mkdir /mysql/{3307,3308}/{data,etc,socket,log,pid} -pv
touch /mysql/3307/log/mysql.log
touch /mysql/3308/log/mysql.log
权限修改
chown -R mysql.mysql /mysql
chown -R mysql.mysql /user/local/mysql
准备数据库数据文件(初始化各个实例:初始化完后会在日志中生成密码,记得保存,初始化密码用到;如果没有生成 执行 grep ‘temporary password‘ /var/log/mysqld.log查找 )
/usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/mysql/3307/data/ --basedir=/usr/local/mysql
/usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/mysql/3308/data/ --basedir=/usr/local/mysql
开启各实例的SSL连接
/usr/local/mysql/bin/mysql_ssl_rsa_setup --initialize --user=mysql --datadir=/mysql/3307/data/ --basedir=/usr/local/mysql
/usr/local/mysql/bin/mysql_ssl_rsa_setup --initialize --user=mysql --datadir=/mysql/3308/data/ --basedir=/usr/local/mysql
--basedir:mysql的安装目录
--datadir:数据库的数据文件目录
准备配置文件3308
vim /mysql/3308/etc/my.cnf
[mysqld]
port=3308
datadir=/mysql/3308/data
socket=/mysql/3308/socket/mysql.sock
sql_mode = ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
[mysqld_safe]
log-error=/mysql/3308/log/mariadb.log
pid-file=/mysql/3308/pid/mariadb.pid
准备配置文件3307
[mysqld]
port=3307
datadir=/mysql/3307/data
basedir=/usr/local/mysql
socket=/mysql/3307/socket/mysql.sock
sql_mode = ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
[mysqld_safe]
log-error=/mysql/3307/log/mysql.log
pid-file=/mysql/3307/pid/mysql.pid
准备启动脚本(3307 3308)
vim /etc/init.d/mysql_3307
#!/bin/bash
#chkconfig: 345 80 2
port=3307
mysql_user="root"
mysql_pwd=" "
cmd_path="/usr/local/mysql/bin"
mysql_basedir="/mysql"
mysql_sock="${mysql_basedir}/${port}/socket/mysql.sock"
function_start_mysql()
{
if [ ! -e "$mysql_sock" ];then
printf "Starting MySQL...\n"
${cmd_path}/mysqld_safe --defaults-file=${mysql_basedir}/${port}/etc/my.cnf &> /dev/null &
else
printf "MySQL is running...\n"
exit
fi
}
function_stop_mysql()
{
if [ ! -e "$mysql_sock" ];then
printf "MySQL is stopped...\n"
exit
else
printf "Stoping MySQL...\n"
${cmd_path}/mysqladmin -u ${mysql_user} -p${mysql_pwd} -S ${mysql_sock} shutdown &> /dev/null
fi
}
function_restart_mysql()
{
printf "Restarting MySQL...\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: ${mysql_basedir}/${port}/bin/mysqld {start|stop|restart}\n"
esac
3308 启动脚本改下端口即可
启动
/etc/init.d/mysql_3307 start
ss -antpu |grep 3307
ps -ef |grep 3307
加入开机启动
chkconfig --add mysql_3307
chkconfig --add mysql_3308
chkconfig --list
登录方式三种
mysql -uroot -h127.0.0.1 -P 3307 -p密码
mysql -uroot -S /mysql/3307/socket/mysql.sock -p密码
mysql -S /mysql/3307/socket/mysql.sock -p
输入之前初始化生成的密码,进入进行密码修改才能操作
set password=password(‘123456‘);
设置远程连接mysql:
GRANT ALL PRIVILEGES ON . TO ‘用户‘@‘%‘ IDENTIFIED BY ‘password‘ WITH GRANT OPTION;
FLUSH PRIVILEGES;
标签:iad 远程连接mysql sage ssl ide default 数据 mod cti
原文地址:https://blog.51cto.com/13293070/2411642