主从mysql架设
二进制安装mysql
tar xvf mysql-5.1.46-linux-i686-glibc23.tar -C /usr/local
cd /usr/local
ln -sv mysql-5.1.46-linux-i686-glibc23.tar mysql
cd mysql
groupadd mysql
useradd -g mysql -s /sbin/nologin -M -r mysql
mkdir /mysql/data
chown -R mysql.mysql /mysql/data
-r :加一系统用户
cd /usr/local/mysql
chown mysql:mysql . -R
#use mysql to init
scripts/mysql_install_db --user=mysql --datadir=/var/mysql/data
chown root . -R
chown mysql data/ -R
cp support-files/my-large.cnf /etc/my.cnf
################################
vim /etc/my.cnf
datadir = /var/mysql/data
启动mysql
bin/mysqld_safe --user=mysql &
netstat -nutlp | grep 3306
vim /etc/profile
#add
PATH=$PATH:/usr/local/mysql/bin
. /etc/profile
#move include file
vim /etc/ld.so.conf.d/mysql.conf
#add
/usr/local/mysql/lib
#reread configure
ldconfig -v
ln -sv /usr/local/mysql/include /usr/include/mysql
ls /usr/include/mysql/
#service mysql start
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
service mysqld restart
注意如果不删匿名用户,即便是你设了root密码只要输入
mysql -u.. 回车就可以进入数据库系统
-u 后跟任意字符
主从mysql工作的原理图:
主mydsql配置:
1. grant replication slave, replication client on *.* to tom@‘192.168.0.%’ identified by '123456';
2.
log_bin = mysql-bin
server_id = 1
show master status
从mysql配置:
3。server_id = 2
relay_log = mysql-relay-bin
log_slave_updates = 1
read_only = 1
mysql
mysql>change master to myster host ="server1"
mysql>maser_user='rep1'
mysql>master_password ='password',
mysql>master log_file='mysql-bin.001',
mysq>master_log_pos=0;
show slave status\G
start slave