1:进入服务器:
Last login: Fri Aug 23 08:34:02 on ttys003
CharlesdeMac-mini:~ charles$ ssh root@111.33.3.252
root@111.33.3.252's password:
Last login: Thu Aug 22 17:01:32 2019 from 114.222.208.84
Welcome to Alibaba Cloud Elastic Compute Service !
[root@lha ~]# ls
2:登录mysql:
[root@lha ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8000
Server version: 5.7.26 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
3:查看编码方式是否为utf8:
mysql> show variables like '%char%';
+--------------------------------------+----------------------------+
| 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/ |
| validate_password_special_char_count | 1 |
+--------------------------------------+----------------------------+
9 rows in set (0.01 sec)
mysql>
确保图中标识为utf-8
4:退出mysql:
mysql> quit
Bye
[root@lha ~]#
5:进入mysql配置文件:vim /etc/my.cnf 添加如下配置语句:
[client]
default-character-set=utf8
[mysqld]
character-set-server=utf8
wait_timeout=1814400
:wq保存配置
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
:wq
6:重启mysql:
[root@lha ~]# systemctl restart mysqld
[root@lha ~]#
7:在查看查看编码方式是否为utf8:
show variables like '%char%';