单个mysql安装参考
http://www.williamsang.com/archives/1304.html
准备工作
yum -y install wget gcc-c++ cmake make bison ncurses-devel perl unzip
# 增加一个名为 mysql的用户。
# groupadd mysql
# useradd mysql -g mysql -M -s /sbin/nologin
解压并安装MySQL
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/data/mysqldb -DMYSQL_TCP_PORT=3344 -DENABLE_DOWNLOADS=1
make
make install
# cd /usr/local/mysql
# chown -R mysql:mysql . (#这里最后是有个.的大家要注意# 为了安全安装完成后请修改权限给root用户)
# chown -R root:mysql . (将权限设置给root用户,并设置给mysql组, 取消其
# chown -R mysql:mysql ./data (数据库存放目录设置成mysql用户mysql组)
1. 初始化数据库
scripts/mysql_install_db --user=mysql
2. cp support-file/my-medium.cnf $basedir/my.cnf
修改my.cnf
[mysqld]
basedir=xxx
datadir=xxx
socket=/tmp/mysqlxxx.sock
port=xxx
3. cp support-file/mysql.server /etc/init.d/mysqlxxx
修改mysqlxxx
basedir=xxx
datadir=xxx
4. service mysqlxxx start
5. 登录./mysql -uroot -S /tmp/mysqlxxx.sock
主从库配置:
1. 修改配置文件
master
修改my.cnf
[quote]server-id=3
log-bin=mysql-bin
binlog-do-db=mmusic[/quote]
slave
修改my.cnf
[quote]server-id=4
#仅同步单个表
replicate-wild-do-table=mmusic.users
replicate-wild-do-table=mmusic.smsconfiginfo[/quote]
2. 对应用户
master 命令行
[quote]grant replication slave on *.* to root@'%' identified by 'slave';
flush privileges;
show master status;[/quote]
slave 命令行
[quote]reset slave;
CHANGE MASTER TO MASTER_HOST='122.227.164.118', MASTER_PORT=3603, MASTER_USER='root', MASTER_PASSWORD='slave',MASTER_LOG_FILE='mysql-bin.000009',MASTER_LOG_POS= 107;
slave start;
show slave status;[/quote]
问题备注:
如果64位系统安装32位的安装包,会遇到异常:
libaio.so.1: cannot open shared object file: No such file or directory
这时执行命令: yum -y install libaio.so.1 就好了
http://www.williamsang.com/archives/1304.html
准备工作
yum -y install wget gcc-c++ cmake make bison ncurses-devel perl unzip
# 增加一个名为 mysql的用户。
# groupadd mysql
# useradd mysql -g mysql -M -s /sbin/nologin
解压并安装MySQL
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/data/mysqldb -DMYSQL_TCP_PORT=3344 -DENABLE_DOWNLOADS=1
make
make install
# cd /usr/local/mysql
# chown -R mysql:mysql . (#这里最后是有个.的大家要注意# 为了安全安装完成后请修改权限给root用户)
# chown -R root:mysql . (将权限设置给root用户,并设置给mysql组, 取消其
# chown -R mysql:mysql ./data (数据库存放目录设置成mysql用户mysql组)
1. 初始化数据库
scripts/mysql_install_db --user=mysql
2. cp support-file/my-medium.cnf $basedir/my.cnf
修改my.cnf
[mysqld]
basedir=xxx
datadir=xxx
socket=/tmp/mysqlxxx.sock
port=xxx
3. cp support-file/mysql.server /etc/init.d/mysqlxxx
修改mysqlxxx
basedir=xxx
datadir=xxx
4. service mysqlxxx start
5. 登录./mysql -uroot -S /tmp/mysqlxxx.sock
主从库配置:
1. 修改配置文件
master
修改my.cnf
[quote]server-id=3
log-bin=mysql-bin
binlog-do-db=mmusic[/quote]
slave
修改my.cnf
[quote]server-id=4
#仅同步单个表
replicate-wild-do-table=mmusic.users
replicate-wild-do-table=mmusic.smsconfiginfo[/quote]
2. 对应用户
master 命令行
[quote]grant replication slave on *.* to root@'%' identified by 'slave';
flush privileges;
show master status;[/quote]
slave 命令行
[quote]reset slave;
CHANGE MASTER TO MASTER_HOST='122.227.164.118', MASTER_PORT=3603, MASTER_USER='root', MASTER_PASSWORD='slave',MASTER_LOG_FILE='mysql-bin.000009',MASTER_LOG_POS= 107;
slave start;
show slave status;[/quote]
问题备注:
如果64位系统安装32位的安装包,会遇到异常:
libaio.so.1: cannot open shared object file: No such file or directory
这时执行命令: yum -y install libaio.so.1 就好了