first of all, the solution is also found on the Internet, the knowledge to write down to prevent later use。Ubuntu version is 14.04 install MySQL using apt-get command
sudo apt-get install Mysql-server
OK then use Mysql-u root-p to check if it starts properly
Mysql-u root-p
Welcome to the MySQL Monitor. Commands End With; or \g.your MySQL connectionIDIsPanax NotoginsengServer Version:5.5. *-1ubuntu1 (Ubuntu) Copyright (c) -, -, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or Itsaffiliates. Other names trademarks of their respectiveowners. Type'Help ;'Or'\h' forHelp. Type'\c'ToClearThe current input statement.mysql>
This is normally the case.
Before encountering a situation is to the data stored in MySQL contains Chinese is garbled, depressed for a long time.
View character formats in MySQL using show variable like "character%" command
Mysql> Show variables like "character%" , +--------------------------+----------------------------+| 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/|+--------------------------+----------------------------+8 rows in Set (0.00 sec)
My this is after the change, unmodified, character_set_database encoding method is not UTF8
To modify the encoding method, modify the My.cnf file.
sudo gedit/etc/mysql/my.cnf
which adds Default-character-set=utf8 under [client]
Add Character-set-server=utf8 collation-server=utf8_general_ci under [mysqld]
Save Exit after
Then use
sudo service MySQL restart
Restart MySQL.
After that, MySQL will be able to store Chinese normally.
##############################################################################################
Before the use of python2.7, call MySQL can use MySQLdb, later Python rose to 3.5, found that MYSQLDB can not be used, so Google, find a solution.
There is a pymysql for Python to call MySQL
Installation is also very simple.
First download the installation package in Https://pypi.python.org/pypi/PyMySQL3
After downloading, unzip, go to the folder directory of the package, and then install
Python setup.py Install
After installation, go into Python interactive mode.
That would have been successful.
MySQL Chinese garbled in Ubuntu and call with python3.x