1:
拷贝到另一目录
\MySQL
\bin
\data
\mysql
\test
\share
\charsets
\english
其中data文件去掉除文件夹外的文件
2:
修改my.ini中
port,datadir,basedir,其他参数可选
3:
G:\MySQL3311\bin\mysqld-nt --install MySQL3311 --defaults-file="G:\MySQL3311\my.ini"
Service successfully installed.
4:
net start MySQL3311 (服务不能启动,一般配置文件不规范,和data文件不干净))
5:mysql --port=3311 -uroot -p
------
G:\MySQL3311\bin\mysqld-nt --remove MySQL3311
MySQL3311 Service successfully removed.
数据库同步:
my.ini:
master-host=10.10.10.77 #同步的主db为10.77,即本地从10.77复制
master-port=3307 #同步的主db的端口为3307,即本地从10.77的3307端口复制
master-user=repuser #同步的用户名,此为10.77的db中指定的,不能随意更改
master-password=1q2w3e #同步的帐号密码,此为10.77的db中指定,不得随意更改
server-id=155 #本地的server-id号,统一规定为"1开头+本机ip最好一个段",避免冲突
replicate-do-db=kwang #同步的db为kwnag库
然后重启mysql服务
G:\MySQL3311\bin\mysqldump -h10.10.10.77 -P3311 -S /tmp/mysql.sock3311 -umikeroot -p --default-character-set=utf8 --master-data --databases user_51mike >e:\3311-user.sqlbak.0326
G:\MySQL3333\bin\mysql -uroot -p
source e:\3311-user.sqlbak.0326
如果是同步几个表:
my.ini:
...其他如上
replicate-do-table=kwang_log.log_client_first_login
replicate-do-table=kwang_log.log_user_first_login
replicate-do-table=kwang_log.log_song_play_200903_200903
...
然后重启mysql服务
G:\MySQL3333\bin\mysqldump -h10.10.10.77 -P3333 -S /tmp/mysql.sock3333 -umikeroot -p --default-character-set=utf8 --master-data kwang_log log_client_first_login log_user_first_login log_song_play_200903_200903 >e:\3333-kwang_log.sqlbak.0326
G:\MySQL3333\bin\mysqldump -h10.10.10.77 -P3333 -S /tmp/mysql.sock3333 -umikeroot -p --default-character-set=utf8 --master-data kwang_log log_song_play_201001_201001 >e:\3333-kwang_log.sqlbak.201001
G:\MySQL3333\bin\mysql -uroot -p
create database kwang_log character set utf8 collate utf8_general_ci;
use kwang_log
source e:\3333-kwang_log.sqlbak.201002
G:\MySQL3333\bin\mysqldump -h10.10.10.77 -P3333 -S /tmp/mysql.sock3333 -umikeroot -p --default-character-set=utf8 --master-data kwang_log log_song_play_201002_201002 >e:\3333-kwang_log.sqlbak.02
show slave status\G
显示
...
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: 10.10.10.77
Master_User: repuser
Master_Port: 3311
Connect_Retry: 60
Master_Log_File:
Read_Master_Log_Pos: 4
Relay_Log_File: RS-0042-CMM-relay-bin.000001
Relay_Log_Pos: 4
Relay_Master_Log_File: innerUser.000002
Slave_IO_Running: No
Slave_SQL_Running: No
Replicate_Do_DB: user_51mike
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 671201559
Relay_Log_Space: 332
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
1 row in set (0.00 sec)
...
slave start;
show slave status\G
显示
...
Slave_IO_Running: YES
Slave_SQL_Running: YES
...