63490794 发表于 2021-3-9 11:41:17

MySQL 经常连接不上,应该怎么优化

MySQL 经常连接不上,每次重启MySQL才可以,/etc/my.cnf 应该怎么优化

服务器配置:

CPU:intel xeon E5-2420(两个)
内存:16G (4*4)
硬盘:600GB SAS (3个 300GBRAID 5)

MySQL 8.0.20

licess 发表于 2021-3-9 20:19:18

配置文件都是自动优化过了的
看一下mysql日志和系统日志中mysql停止工作时间的日志

63490794 发表于 2021-3-11 09:26:42

licess 发表于 2021-3-9 20:19
配置文件都是自动优化过了的
看一下mysql日志和系统日志中mysql停止工作时间的日志 ...

mysqli::real_connect(): (08004/1040): Too many connections

max_connections=1000
还需要加大码?

63490794 发表于 2021-3-11 09:53:37


#password   = your_password
port      = 3306
socket      = /tmp/mysql.sock


port      = 3306
socket      = /tmp/mysql.sock
datadir = /home/mysql
skip-external-locking
key_buffer_size = 256M
max_allowed_packet = 1M
table_open_cache = 1024
sort_buffer_size = 4M
net_buffer_length = 8K
read_buffer_size = 4M
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 64M
thread_cache_size = 128
tmp_table_size = 128M
performance_schema_max_table_instances = 6000

explicit_defaults_for_timestamp = true
#skip-networking
max_connections = 1000
max_connect_errors = 100
open_files_limit = 65535
default_authentication_plugin = mysql_native_password

wait_timeout = 60
interactive_timeout = 60

log-bin=mysql-bin
binlog_format=mixed
server-id   = 1
binlog_expire_logs_seconds = 864000
early-plugin-load = ""

default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_data_home_dir = /home/mysql
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /home/mysql
innodb_buffer_pool_size = 1024M
innodb_log_file_size = 256M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION


quick
max_allowed_packet = 16M


no-auto-rehash


key_buffer_size = 256M
sort_buffer_size = 4M
read_buffer_size = 4M
write_buffer_size = 2M


interactive-timeout


malloc-lib=/usr/lib/libjemalloc.so

licess 发表于 2021-3-11 12:38:42

可以增大试试,日志里什么内容?

sunny123456 发表于 2021-3-12 14:19:38

licess 发表于 2021-3-11 12:38
可以增大试试,日志里什么内容?

mysql远程连接慢,就是使用工具连接Mysql比较慢,有什么优化方案吗?????
页: [1]
查看完整版本: MySQL 经常连接不上,应该怎么优化