Ubuntumysql client emma Chinese garbled problem solution Ubuntu
BitsCN.com
Ubuntu mysql client emma Chinese garbled problem solution
Emma is installed with apt-get by default. emma does not support Chinese characters. you can directly modify the source file (python) of the emma program ).
Install emma with apt-get
Sudo apt-get install emma
If you have installed emma and run emma, the program will be created ~ /. Emma/emmarc file to save the configuration. Therefore, you can change the configuration file or directly modify the python source file of emma as follows.
Vim ~ /. Emma/emmarc
Find
Db_encoding = latin1
Change
Db_encoding = utf8
Re-run emma and garbled characters are found. Add This SQL statement before executing all SQL statements,
Set names utf8
After pressing ctrl + enter, OK!
But every time a new user needs to modify the configuration file and add this statement before executing the new SQL statement, it is not very laborious to directly modify the source file of emma, the newly created emmrc configuration file is utf8, and when the database is selected, the "set names utf8" statement is automatically executed.
Install emma in apt-get of ubuntu under the/usr/share/emma directory.
Cd/usr/share/emma/emmalib
Sudo vim _ init _. py
Find
"Db_encoding": "latin1"
Change
"Db_encoding": "utf8"
Save and exit. In the future, the new configuration file will be decoded by utf8 by default. I want to execute the "set names utf8" statement after connecting the data, so
Sudo vim/usr/share/emma/emmalib/mysql_host.py
Jump to the _ use_db (self, name, do_query = True) function around 155 rows and change it to the following:
Def _ use_db (self, name, do_query = True ):
If self. current_db and name = self. current_db.name: return
If do_query:
Self. query ("use '% s"' % name, False)
Self. query ("set names utf8", False)
Try:
Self. current_db = self. databases [name]
Failed T KeyError:
Print "Warning: used an unknown database % r! Please refresh host! /N % s "% (name," ". join (traceback. format_stack ()))
BitsCN.com