cd ${mysql安装目录}
wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.26.tar.gz
tar -zxvf mysql-5.6.26.tar.gz
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.6.26 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
make
make install
注意,对于用 Tars 的 c++进行开发编译的服务,mysql 建议采用静态库,源码编译,避免所有服务器都要安装 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 = /usr/local/mysql
datadir = /usr/local/mysql/data
# port = .....
# server_id = .....
socket = /tmp/mysql.sock
bind-address=${your machine ip}
# 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
注意将 bind-address 改为部署机器的 IP
启动 mysql
service mysql start
chkconfig mysql on
结束 mysql
service mysql stop
添加 mysql 的 bin 路径
vim /etc/profile
PATH=$PATH:/usr/local/mysql/bin
export PATH
vim /etc/ld.so.conf
/usr/local/mysql/lib/
ldconfig
mysql 主从配置可以参考网上教程
master 赋予权限:
GRANT REPLICATION SLAVE ON *.* to 'mysql-sync'@'%' identified by 'sync@appinside'
slave 设置主备同步项
change master to master_host='${备机Ip}',master_user='mysql-sync',master_password='sync@appinside' ,master_log_file='iZ94orl0ix4Z-bin.000004',master_log_pos=611;
stop slave
start slave
show master status\G;
show slave status\G;
注意${备机 Ip}需要修改成备机数据库的 Ip
3 yum 安装
在 mysql 5.7 版本之后删除了源码中的 mysql_install_db.sh 安装脚本,因此上述方法不适用。 yum 安装相对便捷,但是没办法实现自定义安装。如果对自定义安装有需求的请使用源码安装。