《Mysql必读mysql字符编码修改方法 命令行修改mysql字符编码》要点:
本文介绍了Mysql必读mysql字符编码修改方法 命令行修改mysql字符编码,希望对您有用。如果有疑问,可以联系我们。
导读:1、修改数据库字符编码
mysql> alter database mydb character set utf8 ;2、创建数据库时,指定数据库的字符编码
mysql> create da...
MYSQL数据库1、修改数据库字符编码
mysql> alter database mydb character set utf8 ;
MYSQL数据库2、创建数据库时,指定数据库的字符编码
mysql> create database mydb character set utf8 ;
MYSQL数据库3、查看mysql数据库的字符编码
mysql> show variables like 'character%'; //查询当前mysql数据库的所有属性的字符编码
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
MYSQL数据库4、修改mysql数据库的字符编码
mysql> set character_set_client=utf8 ;
mysql> set character_set_connection=utf8 ;
mysql> set character_set_database=utf8 ;
mysql> set character_set_database=utf8 ;
mysql> set character_set_results=utf8 ;
mysql> set character_set_server=utf8 ;
mysql> set character_set_system=utf8 ;
mysql> show variables like 'character%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
MYSQL数据库修改mysql数据库字符集编码
mysql版本:5.0.27
安装mysql时,由于失误导致mysql默认编码为latin1,这样导致中文支持不了,遂想修改mysql编码为utf8.
步骤如下:
一、管理工具-->服务-->停掉mysql服务
二、修改my.ini配置文件:
1.在[client]的port=3306的下面一行添加default-character-set=utf8
2.将[mysql]中的default-character-set=latin1中的latin1改为utf8
3. 将[mysqld]中的default-character-set=latin1中的latin1改为utf8
MYSQL数据库三、重启mysql服务
service mysqld restart
MYSQL数据库四、进入mysql命令行,输入以下命令检查
MYSQL数据库mysql> show variables like 'character_set_%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
MYSQL数据库mysql> show variables like 'collation_%';
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+----------------------+-----------------+
《Mysql必读mysql字符编码修改方法 命令行修改mysql字符编码》是否对您有启发,欢迎查看更多与《Mysql必读mysql字符编码修改方法 命令行修改mysql字符编码》相关教程,学精学透。维易PHP学院为您提供精彩教程。
转载请注明本页网址:
http://www.vephp.com/jiaocheng/7419.html