1. Update list apt get
sudo apt-get update
2. Install MySQL server and client
sudo apt-get install mysql-server mysql-client
3. When installing the server, if there is no default password, there is no password. Enter the following command to enter mysql
mysql -u root -p
4. Modify the root password. Note that the password field does not exist and needs to be modified to authentication_ String to modify
use mysql;
update mysql.user set authentication_string=password('root') where user='root' and Host ='localhost';
update user set plugin="mysql_native_password";
flush privileges;
quit;
5. Set the encoding, modify the/etc/MySQL/my.cnf file, and add the following contents:
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
character-set-server=utf8
6. Enter Mysql to view the status (whether the code is utf8)
status or \s
7. Start and close MySQL service
open:service mysql start
close:service mysql stop
restart:service mysql restart