发布网友 发布时间:2022-04-08 09:54
共1个回答
热心网友 时间:2022-04-08 11:24
步骤一:首先在Linux上安装mysql,本文不介绍mysql的安装过程
#yum install mysql
#yum install mysql-server
#yum install mysql-devel
在Cenots7操作系统上,安装mariadb(MariaDB数据库管理系统是MySQL的一个分支,centos7使用),安装命令:yum install mariadb-server mariadb
步骤二:安装之后,修改mysql的配置文件/etc/my.cnf默认编码配置为utf-8
[mysql]
character-set-server = utf8
步骤三:修改之后,重启mysqlf服务(systemctl restart mariadb),重启之后登陆mysql(mysql -umysql -p),使用语句show variable like '%character%;查询结果如下,字符编码已经变成utf-8了。
如果查询结果显示不是UTF-8,就需要检查修改的是否正确,也可以使用sql命令就行修改
set character_set_client = utf8;
set character_set_server = utf8;
set character_set_connection = utf8;
set character_set_database = utf8;
set character_set_results = utf8;
set collation_connection = utf8_general_ci;
set collation_database = utf8_general_ci;
set collation_server = utf8_general_ci;