Delete/install/encode configuration file configuration of ubuntu mysql 5.6
1. Delete MySQL
A. sudo apt-get autoremove -- purge mysql-server *
B. sudo apt-get remove mysql-server
C. sudo apt-get autoremove mysql-server
D. sudo apt-get remove mysql-common (very important)
The above is actually redundant. We recommend that you perform the deletion, installation, and encoding configuration file configuration of ubuntu mysql 5.6 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-server
B. sudo apt-get install mysql-client
C. sudo apt-get install php5-mysql (installation php5-mysql is to connect php and 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 copy
Mysql> 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)
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.