SHO酱的Blog

SHO酱的Blog

MySQL 设置汇总

473
2022-03-11

连接数

  • 查看

    show variables like "max_connections";
  • 设置

    set global max_connections = 1000;
  • 查看当前所有连接

    show full processlist;

超时时间

  • 查看

    show global variables like '%timeout%';
  • 设置

    set global interactive_timeout=100;
    set global wait_timeout=30;

设置用户密码

update mysql.user set authentication_string=password('newPassword') where user='root' and Host = 'localhost';
update mysql.user set authentication_string=password('newPassword') where user='root' and Host = '%';

alter user 'root'@'localhost' identified by 'newPassword';
alter user 'root'@'%' identified by 'newPassword';

flush privileges;

之后重启 MySQL 服务

参考

Mysql5.7修改root密码教程

设置表名不区分大小写

创建 MySQL 配置文件 my.cnf,并添加如下内容后重启服务

[mysqld]
lower_case_table_names = 1

其中 0:区分大小写,1:不区分大小写

参考

mysql 大写 小写_MySQL大小写问题

修改时区信息

在 Docker 中使用 MySQL 时常常会遇到时区不正确或容器时区与宿主机不统一的问题。可以通过配置my.cnf文件来设置 MySQL 服务的时区。

[mysqld]
default-time_zone = '+8:00'

参考

MySQL修改时区

Mysql最大连接数,TimeOut配置