MySQL 安装
在/etc/yum.repos.d/
下新建文件 mysql.repo 添加内容:
# Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
然后执行:
yum repolist enabled | grep mysql
查看是否添加进 yum 数据源;
执行安装:
yum install mysql-community-server
其中可能出现 gpgkey 的验证错误问题,因为比较急,所以直接修改 mysql.repo 中的 gpgcheck=0跳过了检查;
多实例启动
找到/etc/my.cnf
,修改内容如下:
# This is an example of a my.cnf file for mysqld_multi.
# Usually this file is located in home dir ~/.my.cnf or /etc/my.cnf
[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
user = multi_admin
password = my_password
[mysqld1]
socket = /tmp/mysql.sock
port = 3306
pid-file = /usr/local/mysql/data/hostname.pid
datadir = /usr/local/mysql/data
user = mysql
[mysqld2]
socket = /tmp/mysql.sock2
port = 3307
pid-file = /usr/local/mysql/data2/hostname.pid2
datadir = /usr/local/mysql/data2
user = mysql
指定好每一个实例的数据目录,pid 和 socket;
执行启动:
mysqld_multi start 1,2
此处后面可以跟多个参数,也可以不写;
不写默认启动全部实例;
mysql-client访问:
mysql -S /tmp/mysql.sock -uxxx -pxxx
-S 后接要访问的实例的 socket,其余与普通的访问没有差别;
当然,也可以直接 ip 端口访问;
mysqld_multi 无法关闭实例
关闭命令与开启命令类似;
mysql_multi --password=xxx stop 1,2
但是执行之后,并没有关闭;
这里是因为 mysql_multi 使用的管理用户 multi_admin 并没有 shutdown 权限;
添加权限:
CREATE USER 'multi_admin'@'localhost' IDENTIFIED BY 'multipass';
GRANT SHUTDOWN ON *.* TO 'multi_admin'@'localhost';
之后关闭,成功;
留言