zoukankan      html  css  js  c++  java
  • Linux install mariadb

    1、安装 Mariadb

    yum -y install mariadb mariadb-server

    2、启动 Mariadb

    systemctl start mariadb

    3、设置开机启动

    systemctl enable mariadb

    4、初始化 Mariadb,设置密码

    mysql_secure_installation
    
    # 首先是设置密码,会提示先输入密码
    Enter current password for root (enter for none):<–初次运行密码为空,直接回车
    
    # 设置密码
    Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车
    New password: <– 设置root用户的密码
    Re-enter new password: <– 再输入一次你设置的密码
    
    # 其他配置
    Remove anonymous users? [Y/n] <– 是否删除匿名用户
    
    Disallow root login remotely? [Y/n] <–是否禁止root远程登录,
    
    Remove test database and access to it? [Y/n] <– 是否删除test数据库
    
    Reload privilege tables now? [Y/n] <– 是否重新加载权限表

    5、配置Mariadb字符集

     5.1、配置 /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

    5.2、配置 /etc/my.cnf.d/client.cnf 文件,在[client]中添加如下:

    default-character-set=utf8

    5.3、配置 /etc/my.cnf.d/mysql-clients.cnf 文件,在[mysql]中添加如下:

    default-character-set=utf8

    6、重启 Mariadb

    systemctl restart mairadb

    7、登录 Mariadb 查看字符集是否设置成功

    MariaDB [(none)]> show variables like "%character%";show variables like "%collation%";

    显示为如下:

    +--------------------------+----------------------------+
    | 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/ |
    +--------------------------+----------------------------+
    8 rows in set (0.00 sec)

    +----------------------+-----------------+
    | Variable_name | Value |
    +----------------------+-----------------+
    | collation_connection | utf8_unicode_ci |
    | collation_database | utf8_unicode_ci |
    | collation_server | utf8_unicode_ci |
    +----------------------+-----------------+
    3 rows in set (0.00 sec)

    请相信,这个世界上真的有人在过着你想要的生活。忽晴忽雨的江湖,祝你有梦为马,随处可栖。(LT)

  • 相关阅读:
    使用JdbcTemplate访问数据库
    解决为什么每次打开Eclipse新的workspace需要更新nexus-maven-repository-index问题
    java内存设置
    Eclipse如何解决启动慢
    eclipse的包的加减号展开方式
    maven总结5
    maven总结4
    maven总结3
    maven总结2
    maven总结1
  • 原文地址:https://www.cnblogs.com/ldl326308/p/14532031.html
Copyright © 2011-2022 走看看