Objective:
There are many tutorials on how to install and configure MySQL in the Linux environment online. This article is written because in the configuration of the character set of the time to find some of the online tutorials found and can not be used to cause a toss for a while. The following tutorials are all in-person practice.
MySQL Uninstall completely
First check to see if you have MySQL installed. The code is as follows:
1 Ps-aux|grep MySQL
No content is displayed if not installed, and the following information is displayed if installed:
There are a lot of ways to completely uninstall MySQL, manually to uninstall and delete redundant files is more troublesome, just execute the following three instructions in turn:
Be sure to pay attention to your MySQL version here!
installation of MySQL
The simplest way to install is the command line, enter the code in turn:
1 sudo apt-get install mysql-server2 3 sudo apt-get install mysql-client
Configuration of the MySQL character set
First we open MySQL on the terminal:
1 mysql-uroot-p
Then enter the password to enter MySQL
We then enter the following query statement to see the default character Set settings:
1 show variables like '%character% ';
We'll look at the results:
We can see that our character_set_database and character_set_server two have not yet been set to UTF8 (or GBK). Below we only need to modify the configuration file in MySQL. After exiting MySQL, enter the following code to edit the configuration file at the command line:
1 sudo vim/etc/mysql/my.cnf
If Vim is not installed, it can be opened with the gedit of the system:
1 sudo gedit/etc/mysql/my.cnf
The following only needs to be modified in two places! But be aware
mysql5.5 The following versionsAnd
5.5 or laterThere is a difference, be sure to pay attention to their own version!
mysql5.5 The following versionsModify the following: "
Client"Default-character-set = UTF8"
mysqld】
default-character-set = UTF8
mysql5.5 or laterModify the following: "
Client"Default-character-set = UTF8"
mysqld】
character-set-server = UTF8
Next
Restart MySQLMake the configuration file effective: There are two ways: Mode 1:
1 sudo/etc/init.d/mysql Restart
Mode 2:
1 sudo service MySQL restart
Next go to MySQL, and then look at the character set settings:
You can see that in addition to the system , this is for UTF8.
Complete uninstall and install configuration Character set for MySQL under Linux