MySQL数据库的多实例配置,一台服务器同时运行多个数据库软件。
预先准备一个已经编译好的,可用直接使用的数据库程序,并拷贝到/usr/local/mysql下
mv mysql-5.7.20-linux-glibc2.12-x86_64 /usr/local/mysql
编写本地配置文件:
vim /etc/my.cnf [mysqld_multi] mysqld = /usr/local/mysql/bin/mysqld_safe mysqladmin = /usr/local/mysql/bin/mysqladmin user = root [mysqld1] datadir=/dir1 port=3307 socket=/dir1/mysql1.sock log-error=/dir1/mysql1.err pid-file=/dir1/mysql1.pid [mysqld2] datadir=/dir2 port=3308 socket=/dir2/mysql2.sock log-error=/dir2/mysql2.err pid-file=/dir2/mysql2.pid
本地操作:
/usr/local/mysql/bin/mysqld_multi start 1 启动,并且会告诉你初始密码 /usr/local/mysql/bin/mysql -uroot -pK=#PxxOhk1jb -S /dir1/mysql1.sock 登陆数据库 mysql> alter user root@'localhost' identified by '123456'; 修改密码重新登陆 /usr/local/mysql/bin/mysqld_multi --user=root --password=123456 stop 1 停止服务
新建远程用户后可远程登陆测试:
mysql -u用户 -p密码 -h服务器IP -P服务器端口
发表评论