Mysql 5.5中怎么设置数据库参数,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。
创新互联是少有的成都网站制作、成都网站设计、营销型企业网站、成都微信小程序、手机APP,开发、制作、设计、友情链接、推广优化一站式服务网络公司,从2013年成立,坚持透明化,价格低,无套路经营理念。让网页惊喜每一位访客多年来深受用户好评
--全局级别
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中怎么设置数据库参数问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注创新互联-成都网站建设公司行业资讯频道了解更多相关知识。