第一:
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz tar zxf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.22-linux-glibc2.12-x86_64 /opt/mysql cd /opt/mysql/
mkdir -pv /data/mysql/db && mkdir logs && echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile source /etc/profile
groupadd mysql && useradd -r -g mysql -s /bin/false mysql
第二:
cat << EOF >/opt/mysql/my.cnf
[client]
port = 3306
#socket = /opt/mysql/mysql.sock
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
innodb_open_files = 5000
open_files_limit = 5000
#socket=/opt/mysql/mysql.sock
server-id = 1
log_bin = master-bin.log
relay_log = relay-bin.log
binlog-do-db = cditv_fun
binlog-do-db = cditv_fun_admin
binlog-do-db = cditv
replicate-do-db = cditv_fun
replicate-do-db = cditv_fun_admin
replicate-do-db = cditv
log-slave-updates
expire_logs_days = 10
max_binlog_size = 100M
binlog_format = mixed
binlog-ignore-db = mysql,test,information_schema
slow_query_log_file = /opt/mysql/logs/mysql-show.log
log-error = /opt/mysql/logs/error.log
long_query_time=2
slow_query_log=1
slow_query_log_file=/opt/mysql/data/slow.log
log_queries_not_using_indexes=1
pid-file = /data/mysql/db/mysql.pid
long_query_time = 2
max_connections = 32000
log-queries-not-using-indexes
EOF
init.d文件: mysqld
cp /opt/mysql/support-files/mysql.server /etc/init.d/mysqld
修改:
basedir=/opt/mysql
datadir=/data/mysql/db
第三:
/opt/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/opt/mysql/ --datadir=/data/mysql/db/ --pid-file=/data/mysql/db/
/etc/init.d/mysqld start
mysql -uroot -p 登录修改密码