MySQL 多端口 For Linux
时间:2015-03-09 23:02 来源:linux.it.net.cn 作者:IT
有2种情况,
1 同一个版本,启动多个端口
2 不同版本,启动多端口
同一版本启动多端口很简单
/usr/local/webserver/mysql/bin/mysqld_safe --defaults-file=/var/mysql3306/my.cnf &
/usr/local/webserver/mysql/bin/mysqld_safe --defaults-file=/var/mysql3307/my.cnf &
在my.cnf 里面
[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8
[mysqld]
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8
basedir = /usr/local/webserver/mysql
datadir = /var/mysql/data
port, socket ,datadir 这三个目录区分开就行了, 比如
/var/mysql3306/my.cnf 里面这么写
引用
[client]
port = 3306
socket = /var/mysql3306/mysql.sock
default-character-set = utf8
[mysqld]
port = 3306
socket = /var/mysql3306/mysql.sock
default-character-set = utf8
basedir = /usr/local/webserver/mysql
datadir = /var/mysql3306/data
skip-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
server-id = 1
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
/var/mysql3307/my.cnf 里面这么写
引用
[client]
port = 3307
socket = /var/mysql3307/mysql.sock
default-character-set = utf8
[mysqld]
port = 3306
socket = /var/mysql3307/mysql.sock
default-character-set = utf8
basedir = /usr/local/webserver/mysql
datadir = /var/mysql3307/data
skip-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
server-id = 1
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
命令行下运行
/usr/local/webserver/mysql/bin/mysql -uroot -p123456 -S /var/mysql3306/mysql.sock
默认的 sock 是在 /tmp/mysql.sock ,如果换位置,基本所有的命令都需要 跟上 -S 来指定位置哦
不同版本,多库启动
按照 VPS安装 linux+nginx+php+mysql 打造自己的vps 里面数据库的安装,
--prefix=/usr/local/webserver/mysql/ 这个参数,换个目录就好了
(责任编辑:IT)
有2种情况,
引用
[client]
port = 3306 socket = /var/mysql3306/mysql.sock default-character-set = utf8 [mysqld] port = 3306 socket = /var/mysql3306/mysql.sock default-character-set = utf8 basedir = /usr/local/webserver/mysql datadir = /var/mysql3306/data skip-locking key_buffer_size = 16M max_allowed_packet = 1M table_open_cache = 64 sort_buffer_size = 512K net_buffer_length = 8K read_buffer_size = 256K read_rnd_buffer_size = 512K myisam_sort_buffer_size = 8M server-id = 1 [mysqldump] quick max_allowed_packet = 16M [mysql] no-auto-rehash [myisamchk] key_buffer_size = 20M sort_buffer_size = 20M read_buffer = 2M write_buffer = 2M /var/mysql3307/my.cnf 里面这么写
引用
[client]
port = 3307 socket = /var/mysql3307/mysql.sock default-character-set = utf8 [mysqld] port = 3306 socket = /var/mysql3307/mysql.sock default-character-set = utf8 basedir = /usr/local/webserver/mysql datadir = /var/mysql3307/data skip-locking key_buffer_size = 16M max_allowed_packet = 1M table_open_cache = 64 sort_buffer_size = 512K net_buffer_length = 8K read_buffer_size = 256K read_rnd_buffer_size = 512K myisam_sort_buffer_size = 8M server-id = 1 [mysqldump] quick max_allowed_packet = 16M [mysql] no-auto-rehash [myisamchk] key_buffer_size = 20M sort_buffer_size = 20M read_buffer = 2M write_buffer = 2M 命令行下运行 /usr/local/webserver/mysql/bin/mysql -uroot -p123456 -S /var/mysql3306/mysql.sock 默认的 sock 是在 /tmp/mysql.sock ,如果换位置,基本所有的命令都需要 跟上 -S 来指定位置哦 不同版本,多库启动 按照 VPS安装 linux+nginx+php+mysql 打造自己的vps 里面数据库的安装, --prefix=/usr/local/webserver/mysql/ 这个参数,换个目录就好了 (责任编辑:IT) |