Mysql5.5 garbled Solution

Source: Internet
Author: User
1. Uninstall mysql5.5 first, and delete all mysql folders, including the 1 and HKEY_LOCAL_MACHINE \ SYSTEM \ ControlSet001 \ Services \ Eventlog \ Application \ MySQL directories in the registry.
2. Delete the HKEY_LOCAL_MACHINE \ SYSTEM \ ControlSet002 \ Services \ Eventlog \ Application \ MySQL directory.
3. Delete the HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ Eventlog \ Application \ MySQL directory. 2. reinstall mysql5.5. Select utf83 and modify my when selecting a character set. [mysql] default-character-set = gbk4 In the ini folder, restart the service, and run the following command on the mysql client to view the result.
Mysql> show variables like 'chara % ';
+ -------------------------- + ----------------------------------------------------
----- +
| Variable_name | Value
|
+ -------------------------- + ----------------------------------------------------
----- +
| Character_set_client | gbk
|
| Character_set_connection | gbk
|
| Character_set_database | utf8
|
| Character_set_filesystem | binary
|
| Character_set_results | gbk
|
| Character_set_server | utf8
|
| Character_set_system | utf8
|
| Character_sets_dir | c: \ Program Files \ MySQL Server 5.0 \ share \ chars
Ets \ |
+ -------------------------- + ----------------------------------------------------
----- +
8 rows in set (0.00 sec)
View the table encoding> show create table person; 5. Configure <% @ page language = "java" import = "java. util. * "pageEncoding =" gb2312 "%> <meta http-equiv =" Content-Type "content =" text/html charset = gb2312 "> 6. Add the following Content to connect to the mysql class: set String driverName = "com. mysql. jdbc. driver "; //" org. gjt. mm. mysql. both drivers can be used.
String dbHost = host; // database information
String dbPort = port;
String dbName = dbaName;
String enCoding = "? UseUnicode = true & characterEncoding = gb2312 "; // solve the MySql Chinese problem. It must be written consecutively without spaces.
String userName = usName;
String Psw = psw;
String url = "jdbc: mysql: //" + dbHost + ":" + dbPort + "/" + dbName + enCoding;
Try
{
Class. forName (driverName). newInstance ();
Dbconn = DriverManager. getConnection (url, userName, Psw );
// GetConnection (url, userName, Psw) select an appropriate connection from the driver to connect to the database.
// Return a connection to the URL
} Catch (Exception e ){
Print ("url =" + url); // when an error occurs, print the information of the connected database.
Print ("userName =" + userName );
Print ("Psw =" + Psw );
Print ("Exception:" + e. getMessage (); // get error information
}
If (dbconn! = Null) // dbconn! = Null indicates that the database is successfully connected. It is guaranteed by exceptions !?
Return true;
Else
Return false;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.