mysql 的多实例安装,配置
源码编译安装与单机安装无不同,主要从创建默认数据库开始。
1.创建mysql用户组 useradd -g mysql -u 58 mysql
2.创建两个数据库在 /data1,/data2下面
mkdir /data1 ; mkdir /data2
chown mysql.mysql /data1
chown mysql.mysql /data2
3.创建数据库
./mysql_install_db --basedir=/usr/local/mysql --datadir=/data1 --user=mysql
./mysql_install_db --basedir=/usr/local/mysql --datadir=/data2 --user=mysql
4.修改配置文件,使其可以支持多数据库实例
[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
user = test
password = test
# The MySQL server
[mysqld3306]
port = 3306
socket = /tmp/mysql3306.sock
pid-file = /tmp/mysql3306.pid
basedir = /usr/local/mysql
datadir = /data1
skip-external-locking
key_buffer_size = 16K
max_allowed_packet = 1M
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 128K
server-id = 1
#log-bin=mysql-bin
#binlog_format=mixed
[mysqld3307]
port = 3307
socket = /tmp/mysql3307.sock
pid-file = /tmp/mysql3307.pid
basedir = /usr/local/mysql
datadir = /data2
skip-external-locking
key_buffer_size = 16K
max_allowed_packet = 1M
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 128K
server-id = 1
#log-bin=mysql-bin
#binlog_format=mixed
名称可以自己取,user,password 用于使用mysqladmin命令关闭,打开数据库时使用
5. 启动数据库
mysqld_multi --defaults-file=/etc/my.cnf start 3306
mysqld_multi --defaults-file=/etc/my.cnf start 3307
ps -ef |grep mysql 检查是否启动
mysql -S /tmp/mysql3306.sock 连接数据库
6.建立数据库用户,并设置密码以用于管理及启动
grant all on *.* to test@localhost identified by test;
日记文件默认存放在$database/data目录下,如果出错可以检查这个日记
阅读(927) | 评论(0) | 转发(0) |