mysql5.6 通用二进制安装:
#卸载原有的mysql
yum remove mysql*
ls /etc/my.cnf*
mv /etc/my.cnf* /tmp/
#安装依赖包
yum install make cmake gcc gcc-c++ bison-devel ncurses-devel autoconf automake -y
#添加用户
groupadd mysql
useradd -r -g mysql mysql
#useradd -M -s /sbin/nologin mysql
#创建目录
mkdir -p /usr/local/mysql
mkdir -p /home/mysql
mkdir -p /home/data
mkdir -p /home/mysql/logs
mkdir -p /home/mysql/temp
#添加环境变量
echo 'PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >>/etc/profile
source /etc/profile
cd /soft/
tar xf mysql-5.6.31-linux-glibc2.5-x86_64.tar.gz
cd mysql-5.6.31-linux-glibc2.5-x86_64
mv mysql-5.6.31-linux-glibc2.5-x86_64 /usr/local/mysql
cd /usr/local/mysql/
chown -Rf mysql:mysql /usr/local/mysql
chown -Rf mysql:mysql /home/data
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/home/data --defaults-file=/usr/local/mysql/my.cnf
添加配置文件:
[client]
default-character-set =utf8
[mysqld]
server-id=10
log-bin = mysql-bin
#binlog-ignore-db=mysql
basedir = /usr/local/mysql
datadir = /home/data
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
lower_case_table_names = 1
log_bin_trust_function_creators=1
#复制函数相关、主从多要开启
character-set-server=utf8
max_connections=500
#慢查询日志
long_query_time=2
slow-query-log=On
slow_query_log_file="mysql_slow_query.log"
#将所有没有使用带索引的查询语句全部写到慢查询日志中,设置关闭,需要时再调用 set global log_queries_not_using_indexes=On 打开
log_queries_not_using_indexes=Off
#内存占用优化
innodb_buffer_pool_size = 500M
innodb_buffer_pool_instances = 1
tmp_table_size=20M
max_heap_table_size=20M
改权限:
chown mysql.mysql my.cnf
cp ./support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
/etc/init.d/mysqld start
chkconfig mysqld on
更改root密码:
/usr/local/mysql/bin/mysqladmin -u root password '123456'
#/usr/local/mysql/bin/mysqladmin -u root -h linux2 password 'new-password'
执行安全检查脚本:
/usr/local/mysql/bin/mysql_secure_installation
进入mysql创建slave用户:
GRANT replication slave ON *.* TO 'slave'@'%' IDENTIFIED BY '123456@';