一、不重启数据库修改数据库参数,但是要求重启后还能生效
需要先修改数据库的参数,然后再修改配置文件的参数,这样数据库重启依然生效
[root@localhost bak]# grep key_buffer /etc/my.cnf key_buffer_size = 16K key_buffer_size = 8M [root@localhost bak]# mysql -uroot -pdubin Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 110 Server version: 5.5.32-log Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql> show variables like ‘key_buffer%‘; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | key_buffer_size | 16384 | +-----------------+-------+ 1 row in set (0.00 sec) mysql> set global key_buffer_size=1024*1024*32; Query OK, 0 rows affected (0.00 sec) mysql> show variables like ‘key_buffer%‘; +-----------------+----------+ | Variable_name | Value | +-----------------+----------+ | key_buffer_size | 33554432 | +-----------------+----------+ 1 row in set (0.00 sec) mysql> quit Bye [root@localhost bak]# mysql -uroot -pdubin Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 111 Server version: 5.5.32-log Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql> show variables like ‘key_buffer%‘; +-----------------+----------+ | Variable_name | Value | +-----------------+----------+ | key_buffer_size | 33554432 | +-----------------+----------+ 1 row in set (0.00 sec) mysql> quit Bye [root@localhost bak]# /etc/init.d/mysqld restart Shutting down MySQL.... SUCCESS! Starting MySQL.^[[A......... SUCCESS! [root@localhost bak]# mysql -uroot -pdubin Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.5.32-log Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql> show variables like ‘key_buffer%‘; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | key_buffer_size | 16384 | +-----------------+-------+ 1 row in set (0.00 sec) mysql> set global key_buffer_size=1024*32; Query OK, 0 rows affected (0.00 sec) mysql> quit Bye [root@localhost bak]# vi /etc/my.cnf [root@localhost bak]# /etc/init.d/mysqld restart Shutting down MySQL. SUCCESS! Starting MySQL.. SUCCESS! [root@localhost bak]# mysql -uroot -pdubin Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.5.32-log Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql> show variables like ‘key_buffer%‘; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | key_buffer_size | 32768 | +-----------------+-------+ 1 row in set (0.00 sec)
原文:https://www.cnblogs.com/cnxy168/p/11646770.html