my.cnf


master:


log-bin  = master-bin


log-bin-index = master-bin.index


server-id = 1


配置完重启、生效


创建master复制用户


create user repl_use;


grant replication slave on *.* to repl_user identified by '密码';


grant replication slave,reload,create user,super on *.* to 用户@'地址' with grant option;


slave:

my.cnf文件添加


server-id = 2


relay-log-index =slave-relay-bin.index


relay-log = slave-relay-bin


将slave指向master


change master to master_host = 'ip地址/计算机名', master_port = 3306, master_user='repl_user',master_password='';


start slave;



==========================

修改mysql默认密码


追加my.cnf文件内容并重启:

[mysqld]

skip-grant-tables

skip-grant-tables


输入mysql进入并修改默认密码

use mysql;

update user set password=password('') where user='root';

flush privileges;

quit;


删除追加内容skip-grant-tables,重启后使用新密码登录。