首页 > 数据库技术 > 详细

MySQL备份与恢复(8)不重启数据库修改数据库参数

时间:2019-10-10 11:27:07      阅读:108      评论:0      收藏:0      [点我收藏+]

一、不重启数据库修改数据库参数,但是要求重启后还能生效

    需要先修改数据库的参数,然后再修改配置文件的参数,这样数据库重启依然生效

[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)

 

MySQL备份与恢复(8)不重启数据库修改数据库参数

原文:https://www.cnblogs.com/cnxy168/p/11646770.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!