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.