MySQL manual installation and Chinese Solutions

Source: Internet
Author: User
Tags mysql manual
It took one day to install MySQL5.0.27icc on DebianEtchLinux and use JDBC to test Chinese! The key to the Chinese problem is that all uses UTF-8 encoding, MySQL5 release supports UTF-8, but the default is latin1, Java uses all Unicode internally, so ensure that the JSP page is encoded in UTF-8, official JDBC driver

It took one day to successfully install MySQL 5.0.27 icc On Debian Etch Linux and use JDBC to test Chinese! The key to the Chinese problem is that all uses UTF-8 encoding, MySQL 5 release supports UTF-8, but the default is latin1, Java uses all Unicode internally, so ensure that the JSP page is encoded in UTF-8, official JDBC driver

It took one day to successfully install MySQL 5.0.27 icc On Debian Etch Linux and use JDBC to test Chinese!

The key to the Chinese problem is that all uses UTF-8 encoding, MySQL 5 release supports UTF-8, but the default is latin1, Java uses all Unicode internally, so ensure that the JSP page is encoded in UTF-8, the JDBC driver adopts the official Connector4J 5.0.4, and the Chinese language is normal in the Resin 3.1/Spring 2.0/Hibernate 3.2 Environment.

1. Download "mysql-standard-5.0.27-linux-i686-icc-glibc23.tar.gz", recommended ICC version, said to be 10-20% better than GCC Performance
2. Copy to/usr/local/, extract: tar zxvf mysql-standard-5.x....tar.gz

3. Add users and groups for mysql:

Groupadd mysql
Useradd-g mysql

4. Create a symbolic connection:/usr/local # ln-s mysql-standard-5.x... mysql
5. cd mysql. Change the current directory to/usr/local/mysql/
6. Run the script to initialize the database:./scripts/mysql_install_db -- user = mysql

7. Set permissions:

/Usr/local/mysql # chown-R root.
/Usr/local/mysql # chown-R mysql data
/Usr/local/mysql # chgrp-R mysql

8. Create and modify/etc/my. cnf as needed. Refer to the Configuration:

[Mysqld]

# Set the default value to the INNODB table and support transactions:

Default-storage-engine = INNODB

# Set the default Character Set UTF-8:

Character-set-server = utf8
Collation-server = utf8_general_ci
Default-character-set = utf8

# Disable bdb:

Skip-bdb

9. Start MySQL:

/Usr/local/mysql/bin #./mysqld_safe -- user = mysql &

10. initialize the root password:

/Usr/local/mysql/bin #./mysqladmin-u root-p password "password-of-root"

Enter password: <输入旧口令,直接按enter>

11. log on to the root account to create a database:
/Usr/local/mysql #./mysql-u root-p
Enter password: password-of-root

12. Create a new user:
Mysql> create user test identified by 'test-password ';

13. Create a new database:
Mysql> create database testdb default character set utf8 default collate utf8_general_ci;

Be sure to specify the character set and sort method, both UTF-8, to ensure that the created table also uses the UTF-8.

14. Grant the test user the permission to access testdb from localhost and use the password:

Mysql> grant all on testdb. * to test @ localhost identified by 'test-password ';

Note: to remotely connect to MySQL using JDBC, you must set the test user permission correctly. The MySQL access permission consists of the user name, client machine name, and password, in the preceding example, only the test user is allowed to connect to MySQL through a password on the local machine (localhost.

15. Stop the MySQL server:

/Usr/local/mysql/bin #./mysqladmin-u root-p shutdown
Enter password: password-of-root
STOPPING server from pid file/usr/local/mysql/data/debian. pid
Xxx mysqld ended

Chinese cheats:
All encoding-related settings in/etc/my. cnf should be set to UTF-8, refer to Step 8.

Perform the following steps:

Mysql> status;

Note that the characterset values must be UTF-8. Otherwise, modify/etc/my. cnf. Refer to Step 8.

Mysql> show variables like '% char % ';

Except character_set_filesystem is displayed as binary, all others should be displayed as utf8. If not, modify/etc/my. cnf. Refer to Step 8.

Mysql> show variables like '% collation % ';

The display should all be utf8_general_ci. Otherwise, modify/etc/my. cnf. Refer to Step 8.

Mysqlshow-u root-p-I database-name

Role: show the database details, if you do not see utf8_general_ci, but latin_swedish_ci, indicating that the database code is not UTF-8, Chinese is certainly not normal, delete it, and then refer to Step 13 to re-create a database with a UTF-8.

[Related articles]

  • How to install MySQL 5.0 on windows
  • Install and start MySQL on ArchLinux
  • How to install and test MySQL

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.