原有MySQL数据库,安装多实例教程
#MySQL安装脚本安装好后
创新互联公司专注于灵山网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供灵山营销型网站建设,灵山网站制作、灵山网页设计、灵山网站官网定制、成都微信小程序服务,打造灵山网络公司原创品牌,更为您提供灵山网站排名全网营销落地服务。
mkdir -v /usr/share/mysql/mysql-files
mkdir -vp /data/mysql_data{1..4}
* 修改MySQL二进制包目录的所属用户与所属组
chown root.mysql -R /usr/share/mysql
* 修改MySQL多实例数据目录与 数据导入/导出专放目录的所属用户与所属组
chown mysql.mysql -R /usr/share/mysql/mysql-files /data/mysql_data{1..4}
* 配置MySQL配置文件
cat>>/etc/multi.cnf< [mysqld_multi] mysqld = /usr/sbin/mysqld mysqladmin = /usr/bin/mysqladmin log = /tmp/mysql_multi.log [mysqld1] datadir = /data/mysql_data1 socket = /tmp/mysql.sock1 port = 3307 user = mysql performance_schema = off innodb_buffer_pool_size = 32M bind_address = 0.0.0.0 skip-name-resolve = 0 [mysqld2] datadir = /data/mysql_data2 socket = /tmp/mysql.sock2 port = 3308 user = mysql performance_schema = off innodb_buffer_pool_size = 32M bind_address = 0.0.0.0 skip-name-resolve = 0 [mysqld3] datadir = /data/mysql_data3 socket = /tmp/mysql.sock3 port = 3309 user = mysql performance_schema = off innodb_buffer_pool_size = 32M bind_address = 0.0.0.0 skip-name-resolve = 0 EOF * 初始化各个实例[初始化完成后会自带随机密码在输出日志中]/var/log/mysqld.log /usr/sbin/mysqld --initialize --user=mysql --datadir=/data/mysql_data1 /usr/sbin/mysqld --initialize --user=mysql --datadir=/data/mysql_data2 /usr/sbin/mysqld --initialize --user=mysql --datadir=/data/mysql_data3 * 实例开启 mysqld_multi --defaults-extra-file=/etc/multi.cnf start 测试 mysql -uroot -S /tmp/mysql.sock1 -p 密码在初始化的时候会给root随机密码 grep 'temporary password' /var/log/mysqld.log| awk -F: '{print $4}'|awk 'NR==2{print}' scok2 就将NR==3 rep 'temporary password' /var/log/mysqld.log| awk -F: '{print $4}'|awk 'NR==3{print}' 依次类推 ALTER USER 'root'@'localhost' IDENTIFIED BY 'abc123'; 先改密码 增删点数据对比下另一个实例的内容就可以 create database test3306; show databases; 默认情况下,mysql只允许本地登录,如果要开启远程连接,则需要修改/etc/mysql/my.conf文件。 一、修改/etc/mysql/my.conf 为需要远程登录的用户赋予权限 use mysql; select user, host from user;
找到bind-address = 127.0.0.1这一行
改为bind-address = 0.0.0.0即可
支持root用户允许远程连接mysql数据库
grant all privileges on *.* to 'root'@'%' identified by 'abc123' with grant option;
flush privileges;
当前标题:原有MySQL数据库,安装多实例教程
浏览路径:http://ybzwz.com/article/iposdh.html