In ubuntu14.04, the mysql security and utf8 configuration sets, ubuntu14.04utf8

Source: Internet
Author: User

In ubuntu14.04, the mysql security and utf8 configuration sets, ubuntu14.04utf8

Mysql server can be installed using sudo apt-get install mysql-server. I have installed version 5.6. During installation, you must enter the password of the root account and enter the password as prompted.

Mysql Workbench use sudo apt-get install mysql-workbench security, version does not support mysql-server-5.6, can be downloaded and installed on the mysql official website.

The installation package I downloaded is a mysql-workbench-community-6.2.3-1ubu1404-amd64.deb and can be installed using the sudo dpkg-I mysql-workbench-community-6.2.3-1ubu1404-amd64.deb. Some dependencies may fail to be installed. You can use sudo apt-get-f install to install the dependency, and then run dpkg again for installation.

To connect an application to a mysql database, you must use mysql connector. You can download and install the application on the mysql official website.

My downloaded package is mysql-connector-java-5.1.33.tar.gz, which can be decompressed using sudo tar-zxvf mysql-connector-java-5.1.33.tar.gz.

Configure the mysql-connector-java-5.1.33-bin.jar in CLASSPATH, right-click the eclipse project-> "Build Path"-> "Configure Build Path" for configuration, import mysql-connector-java-5.1.33-bin.jar in libraries-> Add External JARs to connect to the mysql database using java.

Mysql is encoded as latin1 by default. Use the mysql-u root-p command to enter the mysql console.

Enter mysql> show variables like 'character % '; command to display the mysql database encoding.

+ -------------------------- + ---------------------------- +

| 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/|

+ -------------------------- + ---------------------------- +

You can set the default encoding by modifying the mysql configuration file. sudo vim/etc/mysql/my. cnf opens the configuration file.

Find the client configuration [client] and add it below

Default-character-set = utf8

Add in [mysqld]

Character-set-server = utf8

Find [mysql] and add

Default-character-set = utf8

Many users may add default-character-set = utf8 in [mysqld] on the Internet, which may cause mysql startup errors.

Run sudo/etc/init. d/mysql stop to close the mysql service and restart the mysql service with sudo/etc/init. d/mysql start.

Log on to mysql and run the show variables like 'character % 'command to view the encoding of the mysql database.

+ -------------------------- + ---------------------------- +

| Variable_name | Value |

+ -------------------------- + ---------------------------- +

| Character_set_client | utf8 |

| Character_set_connection | utf8 |

| Character_set_database | utf8 |

| Character_set_filesystem | binary |

| Character_set_results | utf8 |

| Character_set_server | utf8 |

| Character_set_system | utf8 |

| Character_sets_dir |/usr/share/mysql/charsets/|

+ -------------------------- + ---------------------------- +


When mysql is installed, the default character set encoding is utf8, but why is garbled characters inserted into the database,

Reconfigure and select the character encoding of the second "Japan"
Change con = DriverManager. getConnection ("jdbc: mysql: // localhost: 3306/test? User = root & password = fang & useUnicode = true & characterEncoding = UTF-8 "); useUnicode = true & characterEncoding = UTF-8 must be added
Try again!

Why UTF8 is used for character encoding when installing mysql? Urgent

UTF8 supports characters in almost all other languages, including Chinese, and is the most space-saving encoding in Unicode. compatibility is also good, in addition to Windows is not consistent, the default encoding of other systems is generally UTF-8. other codes cannot achieve this effect.

Related Article

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.