Today, when a friend is doing a program project, I need to modify MySQL to modify the default character set, can not find me help. Baidu has tried several blog posts in the method, and finally succeeded. But feel those blog post ideas a bit messy, so I summarize, hope can help to meet the same problem people.
Original Blog Address: http://www.cnblogs.com/xingyunblog/p/3836299.html
OK, here's to you:
Modify MySQL to modify the default character set, a total of two methods.
One is by modifying the My.ini file configuration, one through the MySQL command.
(However, the first method is recommended, because the second seems to be less effective, because when I test it, when it is opened again after the command has been successfully changed, it is automatically restored to the original character set.) )
*************************************************************
The first method:
1. First find your MySQL installation path, such as my installation path is:
D:\Program Files\mysql\mysql Server 5.1
2. Open the My.ini file, modify the default character set at [MySQL] and the default character set at [Mysqld], and I've changed the original latin1 to UTF8.
3. Save the file after the modification and restart the MySQL service.
The second method: modified by the MySQL command.
1. Press the shortcut key Ctrl+r, open the Run window, enter CMD and return.
2. Enter "D:" and press ENTER to enter the D packing directory.
3. Switch to the MySQL installation directory and enter the command:
5.1
4. Log in to the database and enter the command: (note that there is no space between-u and Root, there is no space between-p and password).
- -p password
5. The display shows that the landing was successful.
6. View the current MySQL default character set command:
like ' character_set% ';
7. Enter one of the following commands to make a change.
Mysql> SetCharacter_set_client=UTF8; Query OK,0Rows Affected (0.00sec) MySQL> SetCharacter_set_connection=UTF8; Query OK,0Rows Affected (0.00sec) MySQL> SetCharacter_set_database=UTF8; Query OK,0Rows Affected (0.00sec) MySQL> SetCharacter_set_results=UTF8; Query OK,0Rows Affected (0.00sec) MySQL> SetCharacter_set_server=UTF8; Query OK,0Rows Affected (0.00sec) MySQL> SetCharacter_set_system=UTF8; Query OK,0Rows Affected (0.01sec) MySQL> SetCollation_connection=UTF8; Query OK,0Rows Affected (0.01sec) MySQL> SetCollation_database=UTF8; Query OK,0Rows Affected (0.01sec) MySQL> SetCollation_server=UTF8; Query OK,0Rows Affected (0.01Sec
8. View the current MySQL character set command:
MySQL>like'character_set_%';
************************************************************************
There are two ways to restart the MySQL service:
1.dos command;
2. Graphical user interface operation.
************************************************************************************************
The first approach: through DOS commands
1. Press the shortcut key Ctrl+r, open the Run window, enter CMD and return.
2. Stop the MySQL service command:
sc stop MySQL
3. Turn on the MySQL command:
*****************************************************************************
The second method: Figure with the user interface operation.
1. Left mouse button selected My Computer, right click after the selection of management;
or Press the shortcut key Ctrl+r, open the Run window and enter the command:
Services.msc
2. Locate the service under "Services and Applications", specifically:
about this question other write relatively good blog :mysql Modify the default character set