1实验办法
1、安装Mysql8.0
apt install mysql-server
2、登陆数据库,输入mysql接着出现输入密码的提示,输入完密码回车即可
mysql
Welcome to the MySQL monitor.
3、查看数据库,输入show databases;
mysql > show databases;
4、显示当前已有的数据库
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
2设置字符集
1、打开mysql配置文件
sudo vim /etc/mysql/my.cnf
2、找到[mysqld]在下方输入下方代码后,点击Esc并输入:wq保存退出
[mysqld]
init_connect=‘SET collation_connection = utf8_unicode_ci‘init_connect=‘SET NAMES utf8‘character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
3、重启mysql服务
systemctl restart mysql
4、输入mysql 重新进入mysql
mysql
5、输入show variables like ‘%character%‘ 查看字符集
mysql> show variables like ‘%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/ |
+--------------------------+----------------------------+
可以看到,已经成功将字符集更改为utf-8格式