共计 1708 个字符,预计需要花费 5 分钟才能阅读完成。
MySQL 下载教程请参考:http://xiazai.cuohei.com/
装置 MySQL5.7.26
。创立 MySQL 虚构用户
useradd -s /sbin/nologin -M mysql
id mysql
。创立目录
mkdir -p /server/tools
mkdir -p /opt/mysql
mkdir -p /data/mysql/mysql3306/{data,logs}
cd /server/tools
。上传二进制包
rz
yum install -y lrzsz
。解压二进制包
tar xf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
。将软件局部挪动到指定目录
mv mysql-5.7.26-linux-glibc2.12-x86_64 /opt/mysql/mysql-5.7.26
。创立软连贯
ln -s /opt/mysql/mysql-5.7.26/ /usr/local/mysql
。删除 mariadb
rpm -e –nodeps mariadb-libs
。配置文件整顿
vim /data/mysql/mysql3306/my3306.cnf
[mysqld]
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql/mysql3306/data
socket = /data/mysql/mysql3306/mysql.sock
server_id = 1
port = 3306
log_error=/data/mysql/mysql3306/logs/error.log
log_bin=/data/mysql/mysql3306/logs/mysql-bin
binlog_format=row
gtid_mode=on
enforce_gtid_consistency=true
log_slave_updates=1
max_connections=1024
wait_timeout=60
sort_buffer_size=2M
max_allowed_packet=32M
join_buffer_size=2M
innodb_buffer_pool_size=128M
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=32M
innodb_log_file_size=128M
innodb_log_files_in_group=2
binlog_cache_size=2M
max_binlog_cache_size=8M
max_binlog_size=512M
expire_logs_days=7
slow_query_log=on
slow_query_log_file=/data/mysql/mysql3306/logs/slow.log
long_query_time=0.5
log_queries_not_using_indexes=1
。装置 MySQL 依赖包
yum install libaio-devel -y
yum install numactl -y
。更改 MySQL 相干目录的用户组
chown -R mysql:mysql /data/*
。初始化数据库
/usr/local/mysql/bin/mysqld –defaults-file=/data/mysql/mysql3306/my3306.cnf –initialize-insecure –user=mysql –basedir=/usr/local/mysql –datadir=/data/mysql/mysql3306/data
。退出环境变量
vim /etc/profile
export PATH=”/usr/local/mysql/bin:$PATH”
source /etc/profile
。启动 MySQL
mysqld –defaults-file=/data/mysql/mysql3306/my3306.cnf &
。查看是否启动胜利
netstat -lntup |grep mysql
。连贯 mysql
mysql -S /data/mysql/mysql3306/mysql.sock