First Kind
First, modify the My.ini configuration file (MySQL configuration file)
Character_set_server = UTF8 #设置字符集
Restart MySQL database service
View the current database character set
' character% ';
Second, modify the database character set
set UTF8;
PS: After modifying the database character set, the MySQL database needs to be restarted.
Third, modify the table character set
ALTER table name DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci
Iv. modifying the column character set
ALTER table name change column Name column name CHARACTER set UTF8 COLLATE utf8_general_ci null DEFAULT null;
The second Kind
Modifying the encoding format of a table
Modify the encoding format of a field because the table's encoding changes the field's not so also to modify the field modification field can only change
ALTER TABLE ' tablename ' Change ' field name 1 ' Field Name 2 ' VARCHAR (
The ultimate way to modify multiple lines
Set
Third Kind
1: View the current character encoding method
1: View the current character encoding method MySQL> Show variables like'%character%';+--------------------------+----------------------------+| variable_name | Value |+--------------------------+----------------------------+|character_set_client |latin1 || Character_set_connection |latin1 | | Character_set_database |latin1 | | Character_set_filesystem |binary | | Character_set_results |latin1 | | Character_set_server |latin1 | | Character_set_system |utf8 | | Character_sets_dir | /usr/share/mysql/charsets/|+--------------------------+----------------------------+8Rowsinch Set(0.00Sec
When the character encoding is latin1, the user inserts a character type (char) record into the data table, which may not display the character type's data properly when displaying this record, so we modify the MySQL character encoding to UTF8. Actions are as follows: Step 2: Modify the MY.CNF configuration file, as follows (/ETC/MY.CNF):
[client] #password = your_passwordport 3306socket =/var/lib/mysql/Mysql.sock default-character-set=utf8 #设置默认编码为UTF8
Modifying the MySQL character set