不愿意重启MariaDB数据库服务器,但又调整了数据库的相关配置,想立即生效怎么办?下面介绍我尝试通过的方法。#命令行连接数据库
#mysql -u 用户名 -p 回车
[root@localhost my.cnf.d]# mysql -u root -p
Enter password: #这里输入你的密码
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 89
Server version: 5.5.29-MariaDB MariaDB Server, wsrep_23.7.3.rXXXX
Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]#数据库连接成功
注:因为不能使用kb,mb,gb,所以4m用4*1024*1024代替
调整key_buffer_sizeMariaDB [(none)]> set global key_buffer_size=4*1024*1024;
Query OK, 0 rows affected (0.00 sec)
调整tmp_table_sizeMariaDB [(none)]> set global tmp_table_size=2*1024*1024;
Query OK, 0 rows affected (0.00 sec)
调整max_heap_table_sizeMariaDB [(none)]> set global max_heap_table_size=32*1024*1024;
Query OK, 0 rows affected (0.00 sec)
调整query_cache_typeMariaDB [(none)]> set global query_cache_type=0;
Query OK, 0 rows affected (0.00 sec)
调整query_cache_sizeMariaDB [(none)]> set global query_cache_size=0;
Query OK, 0 rows affected (0.00 sec)
调整max_connectionsMariaDB [(none)]> set global max_connections=50;#设置数据库的最大连接数
Query OK, 0 rows affected (0.00 sec)
调整thread_cache_sizeMariaDB [(none)]> set global thread_cache_size=10;
Query OK, 0 rows affected (0.00 sec)
可以通过如下命令检查配置是否生效MariaDB [(none)]> show global variables;#查看所有变量
或者MariaDB [(none)]> show global variables like '%关键字%';#查看相关变量
最后再向配置文件添加新参数,防止重启数据库后恢复原始配置值。
本文介绍如何在不重启MariaDB的情况下使配置更改立即生效。通过调整关键参数如key_buffer_size、tmp_table_size等,并展示了如何验证这些更改。同时提供更新配置文件的方法,以确保重启后配置依然有效。
1315

被折叠的 条评论
为什么被折叠?



