源码mysql5.6
上传mysql安装包到服务器(虚拟机)
<>1.安装依赖和编译工具
yum -y install gcc gcc-c++ cmake ncurses-devel autoconf
<>2.解压MySQL源码安装包
tar zxf mysql-5.6.10.tar.gz cd mysql-5.6.10
<>3.检测、配置
cmake .
<>4.编译
make
<>5.安装
make install
<>6.配置
cd /usr/local/mysql/support-files/
<>6.1 准备配置文件
cp my-default.cnf /etc/my.cnf
<>6.2 准备启动mysql脚本
cp mysql.server /etc/init.d/mysqld
<>6.3 初始化mysql
useradd mysql chown -R mysql.mysql /usr/local/mysql cd /usr/local/mysql/
scripts./mysql_install_db --user=mysql --datadir=/usr/local/mysql/data --basedir
=/usr/local/mysql
<>6.4 给mysql的命令做一个软连接
ln -s /usr/local/mysql/bin/* /usr/local/sbin/
<>6.5 复制启动文件到/etc/init.d/mysql
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
<>7.启动mysql
service mysqld start
<>8.更改配置文件,启用二进制日志,在[mysqld]下面增加如下配置
vim /etc/my.cnf
<>9.给从授权用户(主操作)
mysql> reset master; mysql> grant replication slave on *.* to 'tom'@
'192.168.59.%' identified by '123'; mysql> flush privileges;
<>10.查看二进制日志(主操作)
show master status; +------------------+----------+--------------+-------------
-----+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +------------------
+----------+--------------+------------------+ | mysql-bin.000001 | 331 | | | +-
-----------------+----------+--------------+------------------+
<>11.登录mysql,执行同步master操作
停止slave,停止同步,开始修改信息 stop slave; 写master的信息 change master to -> master_host=
'192.168.189.161', \\master的ip地址 -> master_user='tom', \\登录master使用的用户 ->
master_password='123', \\登录master使用密码 -> master_log_file='mysql-bin.000001',
\\master当前写入的二进制日志文件-> master_log_pos=331; \\当前二进制日志最新的位置 开启从,开始同步 start slave;
<>12.查看slave状态,查看时候成功开始同步
show slave status \G;