During the development process, if garbled characters appear in the database data after restoring the MySQL database, you can solve this problem by changing the default encoding of the database. The following example shows how to modify the default encoding of MySQL to UTF-8: 1. Check the mysql information first # View the database installation location whereis mysql # Log in to the database mysql -u root -p Enter the password as prompted # View the mysql status mysql>status 2. Modify the my.cnf file The directory is /etc/my.cnf If there is no my.cnf file in the system, you need to create this file. For specific steps, please see 3. If it exists, skip step 3 and go directly to step 4. 3. Find files ending with .cnf Command The result is as shown below: Copy any file in the /usr/share/mysql directory in the search results above to the /etc/ directory Command: 4. Edit the my.cnf file Command: Add below [client] default-character-set=utf8 Add below [mysqld] character_set_server=utf8 The above modification method may not take effect due to different MySQL versions. In actual use, basically most of the MySQL will take effect. I have only encountered one unsuccessful modification. The specific reason has not yet been found out due to the limitations of the conditions at the time. If anyone knows the reason, please let me know, I would be very grateful. In addition, if the above modification method does not work, please change the line under [mysqld] to the following line: default-character-set=utf8 5. Restart mysql service mysql restart At this point, after logging in to MySQL, you can view the modification results through Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links You may also be interested in:
|
<<: MySQL Order By Multi-Field Sorting Rules Code Example
>>: JavaScript+HTML to implement student information management system
Solution: Directly in the directory where you dow...
Preface When I went to an interview at a company ...
There are many scripts on the Internet that use e...
<br />Previous article: Seven Principles of ...
Maybe everyone knows that js execution will block...
This article uses an example to describe how to c...
After the green version of mysql5.6 is decompress...
Password Mode PDO::__construct(): The server requ...
Method 1: Use the SET PASSWORD command MySQL -u r...
Table of contents Preface Installation and Usage ...
In the project, you will encounter custom public ...
When I turned on my MAC at night, I found that th...
This article mainly introduces the pie chart data...
This article records the installation and configu...
After nginx is compiled and installed and used fo...