配置yum源
wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
rpm -ivh mysql57-community-release-el7-11.noarch.rpm
yum makecache
安装mysql
yum install mysql-community-server -y
systemctl enable mysqld
systemctl start mysqld
mkdir /var/log/mysql
chown -R mysql.mysql /var/log/mysql
获取mysql初始密码
grep 'temporary password' /var/log/mysqld.log
[root@template-centos7 src]# grep 'temporary password' /var/log/mysqld.log
2021-11-10T08:48:12.717987Z 1 [Note] A temporary password is generated for root@localhost: fp?GPt&wM2ij
配置文件
[client]
port = 3306
socket = /var/log/mysql/mysql.sock
#default-character-set = utf8
[mysql]
prompt=\\u@\\d>
[mysqld]
server-id = 2
port = 3306
bind-address = 0.0.0.0
socket = /var/log/mysql/mysql.sock
skip-name-resolve
datadir = /data/mysql
character-set-server = utf8_bin
max_connections = 1000
open_files_limit = 65535
log-error = /var/log/mysql/error.log
pid-file = /var/log/mysql/mysql.pid
back_log = 256
max_connect_errors = 256
table_open_cache = 2048
max_allowed_packet = 64M
binlog_cache_size = 2M
max_heap_table_size = 128M
sort_buffer_size = 8M
join_buffer_size = 8M
thread_cache_size = 256
#thread_concurrency = 8
query_cache_size = 256M
query_cache_limit = 2M
thread_stack = 192K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 64M
expire_logs_days=30
max_binlog_size = 512M
slow_query_log = 0
long_query_time = 0.5
key_buffer_size = 256M
read_buffer_size = 8M
read_rnd_buffer_size = 8M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
explicit_defaults_for_timestamp=true
log_timestamps=SYSTEM
innodb_file_per_table=ON
innodb_buffer_pool_size = 13G
innodb_thread_concurrency = 16
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 18M
innodb_log_file_size = 512M
innodb_open_files = 65535
innodb_log_files_in_group = 2
innodb_lock_wait_timeout = 120
[mysqldump]
quick
max_allowed_packet = 64M
[mysql]
no-auto-rehash
prompt=\\u@\\d>
[myisamchk]
key_buffer_size = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M
修改密码
# 第一次修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'New_password1';
# 之后修改密码
update mysql.user set authentication_string=password('New_password1') where user='root' ;