Mysql 5.5中怎么设置数据库参数,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。
--全局级别
mysql> show global variables like '%server%';
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| character_set_server | utf8 |
| collation_server | utf8_general_ci |
| server_id | 1 |
+----------------------+-----------------+
3 rows in set (0.00 sec)
mysql> set global character_set_server=gbk;
Query OK, 0 rows affected (0.10 sec)
mysql> show global variables like '%server%';
+----------------------+----------------+
| Variable_name | Value |
+----------------------+----------------+
| character_set_server | gbk |
| collation_server | gbk_chinese_ci |
| server_id | 1 |
+----------------------+----------------+
3 rows in set (0.01 sec)
也可以使用下面方式来修改
mysql> show global variables like 'character_set_server';
+----------------------+--------+
| Variable_name | Value |
+----------------------+--------+
| character_set_server | latin1 |
+----------------------+--------+
1 row in set (0.00 sec)
mysql> set @@global.character_set_server=gbk;
Query OK, 0 rows affected (0.00 sec)
mysql> show global variables like 'character_set_server';
+----------------------+-------+
| Variable_name | Value |
+----------------------+-------+
| character_set_server | gbk |
+----------------------+-------+
1 row in set (0.01 sec)
--会话级别
mysql> set session character_set_server='utf8';
Query OK, 0 rows affected (0.00 sec)
mysql> show global variables like '%server%';
+----------------------+----------------+
| Variable_name | Value |
+----------------------+----------------+
| character_set_server | gbk |
| collation_server | gbk_chinese_ci |
| server_id | 1 |
+----------------------+----------------+
3 rows in set (0.00 sec)
--show variables查询的是会话级别的参数
mysql> show variables like '%server%';
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| character_set_server | utf8 |
| collation_server | utf8_general_ci |
| server_id | 1 |
+----------------------+-----------------+
3 rows in set (0.00 sec)
mysql> show session variables like '%server%';
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| character_set_server | utf8 |
| collation_server | utf8_general_ci |
| server_id | 1 |
+----------------------+-----------------+
3 rows in set (0.00 sec)
即使是使用set global命令设置的参数,在数据库重启后,相关的参数也会失效;如果想让参数永久生效,可以将参数写在配置文件里面。
[root@localhost mysql]# vim /etc/my.cnf
# Character set
character_set_server = gbk
collation_server = gbk_bin
关于Mysql 5.5中怎么设置数据库参数问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注亿速云行业资讯频道了解更多相关知识。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。