First, install the database
1. Get and install MySQL
sudo Install Mysql-server
2. Set the root password (enter the password in the pop-up prompt box)
3, log in the database, enter Mysql-u root-p, followed by the input password prompt, enter the password return can
$ mysql-u Root-penter passwordwelcome to the MySQL monitor.
4, check the database, enter show databases;
MySQL > show databases;
5. Display the current database
+--------------------+| Database |+--------------------+| information_schema | | mysql | | performance_schema |+--------------------+
Second, set character sets
1. Open the MySQL configuration file
sudo vim/etc/mysql/my.cnf
2, find [mysqld] below enter the code below, click ESC and enter: Wq Save exit
[Mysqld]init_connect='SET collation_connection = utf8_unicode_ci'init_ Connect='SET NAMES UTF8'character-set-server=utf8collation- server=Utf8_unicode_ciskip-character-set-client-handshake
3. Restart MySQL Service
$ service MySQL Restart
4. Enter Mysql-u root-p to re-enter MySQL
$ mysql-u root-penter password
5. Enter show variables like '%character% ' to view character set
' %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/|+--------------------------+----------------------------+
As you can see, the character set has been successfully changed to UTF-8 format
Ubuntu installs MySQL and sets the character set to UTF-8