您好,登錄后才能下訂單哦!
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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。