【Mysql】character-set-server参数
时间:2021-07-01 10:21:17
帮助过:6人阅读
[root@rac3 ~]# more /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
old_passwords=1
character-set-server = utf8
关闭数据库服务,并重新启动!
[root@rac3 ~]# mysqladmin shutdown
[root@rac3 ~]# mysqld_safe &
[1] 15102
[root@rac3 ~]# Starting mysqld daemon with databases from /var/lib/mysql
[root@rac3 ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.45 Source distribution
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the buffer.
mysql> show variables like ‘%server%‘;
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| character_set_server | utf8 |
| collation_server | utf8_general_ci |
| server_id | 0 |
+----------------------+-----------------+
3 rows in set (0.00 sec)
--重新建立数据库,查看其默认字符集:为utf8
mysql> create database yql;
Query OK, 1 row affected (0.00 sec)
mysql> use yql;
Database changed
新建表的默认字符集和数据库的默认字符集一致!
mysql> create table t(id int);
Query OK, 0 rows affected (0.00 sec)
mysql> show create table t;
+-------+-------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+-------------------------------------------------------------------------------------+
| t | CREATE TABLE `t` (
`id` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 |
+-------+-------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> show create database yql \G;
*************************** 1. row ***************************
Database: yql
Create Database: CREATE DATABASE `yql` /*!40100 DEFAULT CHARACTER SET utf8 */
1 row in set (0.00 sec)
ERROR:
No query specified
【Mysql】character-set-server参数
标签: