zoukankan      html  css  js  c++  java
  • install mariadb on Centos 7

    1. 检查是否已安装 mariadb

    yum list installed | grep mariadb

    2、安装MariaDB

    如果未安装,执行以下命令安装命令

    yum -y install mariadb mariadb-server

    安装完成MariaDB,首先启动MariaDB

    systemctl start mariadb

    设置开机启动

    systemctl enable mariadb

    2. 修改配置

    修改配置授权远程访问

    vi /etc/my.cnf

    bind-address = <some ip-address> | #bind-address = <some ip-address> 

    创建远程访问用户,并授予访问权限

    mysql
    CREATE USER 'user1'@'internet_ip' IDENTIFIED BY 'the_password'; GRANT ALL ON *.* TO 'user1'@'internet_ip';

    //or reset password if user exists
    SET PASSWORD FOR 'user1'@'localhost' = PASSWORD('the_password');

    3. 设置中文字符集

    vi /etc/my.cnf
    在[mysqld]标签下添加
    #character
    init_connect='SET collation_connection = utf8mb4_unicode_ci'
    init_connect='SET NAMES utf8mb4'
    character-set-server=utf8mb4
    collation-server=utf8mb4_unicode_ci
    skip-character-set-client-handshake
    
    vi /etc/my.cnf.d/client.cnf
    在[client]下添加
    #character
    default-character-set=utf8mb4
    
    vi /etc/my.cnf.d/mysql-clients.cnf
    
    在[mysql]中添加
    
    #character
    
    default-character-set=utf8mb4
    重启mariadb服务,使配置生效
    systemctl restart mariadb

    查看版本

    MariaDB [(none)]> s
    --------------
    mysql  Ver 15.1 Distrib 5.5.68-MariaDB, for Linux (x86_64) using readline 5.1
    
    Connection id:          3
    Current database:
    Current user:           root@localhost
    SSL:                    Not in use
    Current pager:          stdout
    Using outfile:          ''
    Using delimiter:        ;
    Server:                 MariaDB
    Server version:         5.5.68-MariaDB MariaDB Server
    Protocol version:       10
    Connection:             Localhost via UNIX socket
    Server characterset:    utf8mb4
    Db     characterset:    utf8mb4
    Client characterset:    utf8mb4
    Conn.  characterset:    utf8mb4
    UNIX socket:            /var/lib/mysql/mysql.sock
    Uptime:                 1 day 20 hours 48 min 13 sec

    查看字符集是否生效

    mysql> show variables like 'character%';  

    MariaDB [(none)]> show variables like 'character%';
    +--------------------------+----------------------------+
    | Variable_name        | Value                         |
    +--------------------------+----------------------------+
    | character_set_client | utf8mb4 |
    | character_set_connection | utf8mb4 |
    | character_set_database | utf8mb4 |
    | character_set_filesystem | binary |
    | character_set_results | utf8mb4 |
    | character_set_server | utf8mb4 |
    | character_set_system | utf8 |
    | character_sets_dir | /usr/share/mysql/charsets/ |
    +--------------------------+----------------------------+

    log for trouble shooting
    /var/log/mariadb/mariadb.log 

    4. 设置数据库对大小写不敏感

    进入 /etc/my.cnf.d  ,编辑server.cnf
    vi /etc/my.cnf.d/server.cnf
    在[mysqld]下添加
    lower_case_table_names = 1

     reference documents:

    https://www.cnblogs.com/zhanzhan/p/7729981.html

    https://blog.csdn.net/qq_35440040/article/details/86084909

    转载请注明出处, 更多博文请访问https://www.cnblogs.com/guoapeng/
  • 相关阅读:
    移位运算符
    java 链表数据结构
    log4j.properties配置详解
    java异常面试题
    QuickHit项目(输出字符串游戏)
    适配器模式
    java 单例
    sql索引的填充因子多少最好,填充因子的作用?
    聚焦索引和非聚焦索引的区别
    二叉树。。。。
  • 原文地址:https://www.cnblogs.com/guoapeng/p/11939469.html
Copyright © 2011-2022 走看看