The MySQL database is an open-source database that is widely used. The following is a procedure for modifying the character encoding of a MySQL database and converting the character encoding of a table into a Utf-8 method, which a friend can refer to.
MySQL converts the character encoding of a table into Utf-8:
ALTER TABLE Tb_anniversary convert to character set UTF8;
Modify the database MySQL character encoding to UTF8:
Step 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/|+--------------------------+----------------------------+8 Rows in Set (0.00 sec)
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. The operation is as follows:
Step 2: Modify the MY.CNF configuration file, modified as follows (/ETC/MY.CNF):
[client] #password = your_passwordport = 3306socket =/var/lib/mysql/mysql.sockdefault-character-set= UTF8 #设置默认编码为UTF8
, query the details of each field in the current table: Show full columns from table_name;
MySQL modifies the database encoding (database character set) and the method of the character encoding of the table