美文网首页
mysql 字符集修改

mysql 字符集修改

作者: Morgan7 | 来源:发表于2019-06-04 10:21 被阅读0次

    mysql my.cnf文件

    • Linux下一般是/etc/my.cnf
    vim /etc/my.cnf
    
    • my.cnf文件内容
    • 添加 default-character-set = utf8character_set_server=utf8
    [mysqld]
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    # Disabling symbolic-links is recommended to prevent assorted security risks
    symbolic-links=0
    # Settings user and group are ignored when systemd is used.
    # If you need to run mysqld under a different user or group,
    # customize your systemd unit file for mariadb according to the
    # instructions in http://fedoraproject.org/wiki/Systemd
    character_set_server=utf8
    [mysql]
    default-character-set = utf8
    [mysql.server]
    default-character-set = utf8
    [client]
    default-character-set = utf8
    [mysqld_safe]
    log-error=/var/log/mariadb/mariadb.log
    pid-file=/var/run/mariadb/mariadb.pid
    #
    # include all files from the config directory
    #
    !includedir /etc/my.cnf.d
    default-character-set = utf8
    

    查看mysql启动日志

    cd /var/log/mariadb/
    vi mariadb.log
    

    停止

    systemctl stop mariadb.service
    

    启动

    systemctl start mariadb.service
    

    创建数据库 指定字符集

    CREATE DATABASE Doctors DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
    

    更改字符集

    ALTER DATABASE db_name DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
    

    相关文章

      网友评论

          本文标题:mysql 字符集修改

          本文链接:https://www.haomeiwen.com/subject/zkafsqtx.html