安装
tar -zxvf mysql-5.7.43-el7-x86_64.tar.gz -C /usr/local/
cd /usr/local
mv mysql-5.7.43-el7-x86_64 mysql
cd /usr/lcoal/mysql
groupadd mysql
useradd -r -M -g mysql mysql
chown -R mysql:mysql ./
创建目录
mkdir /data
mkdir /data/mysql
备份并修改配置文件
cp /etc/my.cnf /etc/my.cnf.default.bak
vi /etc/my.cnf
修改配置文件
[mysqld]
socket=/usr/local/mysql/mysql.sock
user=mysql
symbolic-links=0
datadir=/data/mysql
pid-file=/usr/local/mysql/mysqld.pid
innodb_file_per_table=1
log-slave-updates = on
log-error=/usr/local/mysql/logs/mysql.err
log-bin=/usr/local/mysql/logs/mysql-bin
log-bin-index=/usr/local/mysql/logs/mysql-bin.index
relay-log=/usr/local/mysql/logs/relay-bin
relay-log-index=/usr/local/mysql/logs/relay-bin.index
binlog-do-db = zcms
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 2
innodb_lock_wait_timeout = 50
character-set-server=utf8
max_connections=20000
long_query_time = 1
slow_query_log=1
slow_query_log_file=/usr/local/mysql/logs/mysql-slow.log
expire_logs_days=7
query_cache_type = 1
query_cache_size = 10M
server-id=1
sync-binlog=1
lower_case_table_names=1
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[client]
port=3306
socket=/usr/local/mysql/mysql.sock
[mysqld_safe]
log-error=/usr/local/mysql/logs/mysqld.log
pid-file=/usr/local/mysql/mysqld.pid
初始化
./bin/mysqld --initialize --basedir=/usr/local/mysql --datadir=/data/mysql --user=mysql
报错
2023-12-26T08:27:15.600641Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2023-12-26T08:27:15.600750Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2023-12-26T08:27:15.600758Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2023-12-26T08:27:15.605611Z 0 [ERROR] Could not open file '/usr/local/mysql/logs/mysql.err' for error logging: No such file or directory
2023-12-26T08:27:15.605637Z 0 [ERROR] Aborting
新建文件夹
cd /usr/local/logs
mkdir logs
chown -R mysql:mysql ./
密码
cat /usr/local/mysql/logs/mysql.err
标签:bin,log,安装,MySQL,usr,mysql,local,logs
From: https://www.cnblogs.com/zdtiio/p/17928410.html