MySQL.配置MariaDB的字符集

时间:2023-03-09 18:48:35
MySQL.配置MariaDB的字符集

配置MariaDB的字符集

  环境:

    操作系统:CentOS Linux release 7.x

mariadb安装及配置

  yum install mariadb-server mariadb #安装

  systemctl start mariadb #启动MariaDB

  systemctl stop mariadb #停止MariaDB

  systemctl restart mariadb #重启MariaDB

  systemctl enable mariadb #设置开机启动

配置MariaDB的字符集

  编辑文件/etc/my.cnf ,指令如下:

    vim /etc/my.cnf

    在[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
  

      MySQL.配置MariaDB的字符集


  编辑文件/etc/my.cnf.d/client.cnf,指令如下:
    vim /etc/my.cnf.d/client.cnf
    在[client]中添加如下内容:
      default-character-set=utf8
      MySQL.配置MariaDB的字符集

  编辑文件/etc/my.cnf.d/mysql-clients.cnf,指令如下:

    vim /etc/my.cnf.d/mysql-clients.cnf

    在[mysql]中添加如下内容: 

      default-character-set=utf8

      MySQL.配置MariaDB的字符集

  全部配置完成,重启mariadb,指令如下 :

    systemctl restart mariadb

  

  之后进入MariaDB查看字符集

    mysql> show variables like "%character%";

    mysql> show variables like "%collation%";

    MySQL.配置MariaDB的字符集

如有问题,欢迎纠正!!!

如有转载,请标明源处:https://www.cnblogs.com/Charles-Yuan/p/9742747.html