Ubuntu mysql 5.6 deletes/installs/encodes the configuration file, ubuntu5.6
1. Delete MySQL
A. sudo apt-get autoremove -- purge mysql-server * B. sudo apt-get remove mysql-serverc. sudo apt-get autoremove mysql-serverd. sudo apt-get remove mysql-common (very important)
In fact, some of the above are redundant. We recommend that you execute them in sequence.
2. Clear residual data
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
3. Install mysql
A. sudo apt-get install mysql-serverb. sudo apt-get install mysql-clientc. sudo apt-get install php5-mysql (installing the php5-mysql is to connect php to mysql)
After installation, you can start the mysql service. You can also use the following command to manage the mysql service.
Service mysql start (start mysql) service mysql stop (disable mysql) service mysql restart (restart mysql)
Run the following command to access mysql:
Mysql-u root-p 123456 (123456 sets your own password)
View Encoding
show variables like '%character%'; [python] view plain copymysql> show variables like 'character%'; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+
Some latin1 encoding causes Chinese garbled characters. Modify the encoding configuration below.
Cd/etc/mysql/my. cnf (you should pay attention to your mysql version and system for encoding modification, which may be different) sudo chmod 775 my. cnf sudo vim my. cnf
Add the following content after the file
[python] view plain copy[mysqld] character-set-server=utf8
ESC +: wq save and exit
Use service mysql restart to restart the mysql service.