作者:丽sd园印章 | 来源:互联网 | 2014-05-29 08:43
不愿意重启MariaDB数据库服务器,但又调整了数据库的相关配置,想立即生效怎么办?下面介绍我尝试通过的方法。#命令行连接数据库#mysql-u用户名-p回车[root@localhostmy.cnf.d]#mysql-uroot-pEnterpassword:#这里输入你的密码WelcometotheMariaDBm
不愿意重启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_size
MariaDB [(none)]> set global key_buffer_size=4*1024*1024;
Query OK, 0 rows affected (0.00 sec)
调整tmp_table_size
MariaDB [(none)]> set global tmp_table_size=2*1024*1024;
Query OK, 0 rows affected (0.00 sec)
调整max_heap_table_size
MariaDB [(none)]> set global max_heap_table_size=32*1024*1024;
Query OK, 0 rows affected (0.00 sec)
调整query_cache_type
MariaDB [(none)]> set global query_cache_type=0;
Query OK, 0 rows affected (0.00 sec)
调整query_cache_size
MariaDB [(none)]> set global query_cache_size=0;
Query OK, 0 rows affected (0.00 sec)
调整max_connections
MariaDB [(none)]> set global max_cOnnections=50;#设置数据库的最大连接数
Query OK, 0 rows affected (0.00 sec)
调整thread_cache_size
MariaDB [(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 '%关键字%';#查看相关变量
最后再向配置文件添加新参数,防止重启数据库后恢复原始配置值。