下载mysql5.6.23
检测服务是否有mysql
rpm -qa |grep mysql
显示mysql-libs-5.1.73-5.el6_6.x86_64删除低版本mysql
yum remove mysql-libs解压 tar -zxvf mysql-5.6.23.tar.gz
cd mysql-5.6.23安装依赖包
sudo yum install cmake gcc-c++ ncurses-devel perl-Data-Dumper编译
cmake .
make安装,会在/use/local/下生成mysql
sudo make install添加mysql用户和组
cd /usr/local/mysql
sudo chown -R mysql .
sudo chgrp -R mysql .
sudo scripts/mysql_install_db --user=mysql
sudo chown -R root .
sudo chown -R mysql data创建数据库目录
mkdir /data/mysql
chown mysql:mysql /data/mysql删除默认配置文件
cd /etc
sudo rm -fr my.cnf my.cnf.d新建配置文件,配置文件见my.cnf文件
初始化mysql
sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &初始化数据库,会在/data/mysql/目录下创建mysql数据库,需要在mysql安装目录
/usr/local/mysql/scripts/mysql_install_db --user=mysql配置环境变量
mysql environment
export PATH=/usr/local/mysql/bin:$PATH
alias mysql_start="mysqld_safe&"
alias mysql_stop="mysqladmin -uroot -p shutdown"添加开机启动
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/
chkconfig --add mysql启动数据库
/etc/init.d/mysql start-
修改密码
mysql
use mysql;
UPDATE user SET password = PASSWORD('yicha.123') WHERE user = 'root';
FLUSH PRIVILEGES;/etc/inin.d/mysql restart
主从配置
主:log-bin=mysql-bin
server-id=1
binlog_format=mixed
重启服务
从:log-bin=mysql-bin
binlog_format=mixed
server-id=2
relay-log-index = slave-relay-bin.index
relay-log = slave-relay-bin
sync_master_info = 1
sync_relay_log = 1
sync_relay_log_info = 1
重启服务,登录
change master to master_host='10.10.63.106',master_user='mysqlrsync',master_password='mysql';
start slave;
show slave status\G;
my.inf文件
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
user=mysql
datadir=/data/mysql
default-storage-engine=MyISAM