ITPub博客

首页 > 数据库 > MySQL > 动态修改MYSQL配置参数

动态修改MYSQL配置参数

MySQL 作者:千寻ccxx 时间:2016-12-21 16:15:44 0 删除 编辑

MySQL数据库也像Oracle数据库一样,可以动态的修改参数,可以修改会话级变量只对当前会话产生影响;也可以修改全局变量,对所有新连接的会话都产生影响。

修改会话级变量

用show variables 命令查看当前参数的值,like 'pattern'用于模式匹配,查找指定的参数

mysql> show variables like '%sort_buffer_size%';
+---------------------------+------------+
| Variable_name             | Value      |
+---------------------------+------------+
| sort_buffer_size          | 6291448    |
+---------------------------+------------+
1 rows in set (0.00 sec)

用set SESSION命令设置会话级变量的新值

mysql> set SESSION sort_buffer_size=7000000;
Query OK, 0 rows affected (0.00 sec)

--修改会话级变量对当前会话来说立刻生效
mysql> show variables like '%sort_buffer_size%';       
+---------------------------+------------+
| Variable_name             | Value      |
+---------------------------+------------+
| sort_buffer_size          | 7000000    |
+---------------------------+------------+
1 rows in set (0.00 sec)

mysql> exit
Bye
退出重新连接后,此参数恢复原值
[root@devdbc_stb root]# mysql
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 40 to server version: 5.0.37-log

Type 'help;' or '/h' for help. Type '/c' to clear the buffer.

mysql> show variables like '%sort_buffer_size%';       
+---------------------------+------------+
| Variable_name             | Value      |
+---------------------------+------------+
| sort_buffer_size          | 6291448    |
+---------------------------+------------+
1 rows in set (0.00 sec)

修改全局变量
[root@devdbc_stb root]# mysql
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 40 to server version: 5.0.37-log

Type 'help;' or '/h' for help. Type '/c' to clear the buffer.

mysql> show variables like '%sort_buffer_size%';       
+---------------------------+------------+
| Variable_name             | Value      |
+---------------------------+------------+
| sort_buffer_size          | 6291448    |
+---------------------------+------------+
1 rows in set (0.00 sec)

用set GLOBAL 命令设置全局变量

mysql> set GLOBAL sort_buffer_size = 7000000;
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like '%sort_buffer_size%';        
+---------------------------+------------+
| Variable_name             | Value      |
+---------------------------+------------+
| sort_buffer_size          | 6291448    |
+---------------------------+------------+
1 rows in set (0.00 sec)
当前此参数的值并不发生变化,先退出,然后重新连进去
mysql> exit
Bye
[root@devdbc_stb root]# mysql
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 41 to server version: 5.0.37-log

Type 'help;' or '/h' for help. Type '/c' to clear the buffer.

mysql> show variables like '%sort_buffer_size%';
+---------------------------+------------+
| Variable_name             | Value      |
+---------------------------+------------+
| sort_buffer_size          | 7000000    |
+---------------------------+------------+
1 rows in set (0.00 sec)
新的参数值生效


 新的参数值生效 这些参数的改变在重启MYSQL服务的时候,都将失效复原,如果想要重启的时候也载入,则需要修改配置文件。

顶 0 踩 0
 
 

我的同类文章

database(35)
http://blog.csdn.net 更多文章
.blog-ass-articl dd { color: #369; width: 99%; /*修改行*/ float: left; overflow: hidden; font: normal normal 12px/23px "SimSun"; height: 23px; margin: 0; padding: 0 0 0 10px; margin-right: 30px; background: url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px; }

参考知识库

img

MySQL知识库

17408关注|1442收录

img

Oracle知识库

3401关注|252收录

猜你在找
查看评论

  暂无评论

* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
.tag_list { background: none repeat scroll 0 0 #FFFFFF; border: 1px solid #D7CBC1; color: #000000; font-size: 12px; line-height: 20px; list-style: none outside none; margin: 10px 2% 0 1%; padding: 1px; } .tag_list h5 { background: none repeat scroll 0 0 #E0DBD3; color: #47381C; font-size: 12px; height: 24px; line-height: 24px; padding: 0 5px; margin: 0; } .tag_list h5 a { color: #47381C; } .classify { margin: 10px 0; padding: 4px 12px 8px; } .classify a { margin-right: 20px; white-space: nowrap; } #popup_mask { position: absolute; width: 100%; height: 100%; background: #000; z-index: 9999; left: 0px; top: 0px; opacity: 0.3; filter: alpha(opacity=30); display: none; }
    个人资料
    • 访问:1896237次
    • 积分:24427
    • 等级:
    • 排名:第208名
    • 原创:559篇
    • 转载:290篇
    • 译文:3篇
    • 评论:299条
    文章存档

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31401161/viewspace-2131143/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: Linux常用shell命令
请登录后发表评论 登录
全部评论

注册时间:2016-10-10

  • 博文量
    186
  • 访问量
    141025