zoukankan      html  css  js  c++  java
  • CentOS安装MariaDB

    本文总结自己的实践过程,文末有相关参考链接。

    安装

    前往官网选择版本
    将以下内容创建到文件/etc/yum.repos.d/MariaDB.repo中(版本为10.5)

    # MariaDB 10.5 [Stable] CentOS repository list - created 2020-09-09 08:33 UTC
    # https://mariadb.org/download-test/
    [mariadb]
    name = MariaDB
    baseurl = https://mirrors.tuna.tsinghua.edu.cn/mariadb/yum/10.5/centos7-amd64
    gpgkey=https://mirrors.tuna.tsinghua.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
    gpgcheck=1
    

    用以下命令安装MariaDB

    yum install MariaDB-server MariaDB-client
    

    注:使用efcore并且当你改了实体字段名做自动迁移时,可能会出现异常,原因是低版本不支持ALTER TABLE XX RENAME COLUMN OLDXXX TO NEWXX语法,升级到高版本即可,亲测V10.5支持。

    初始化

    执行mysql_secure_installation命令,按步骤操作即可,如下

    # mysql_secure_installation
    
    NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
          SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
    
    In order to log into MariaDB to secure it, we'll need the current
    password for the root user.  If you've just installed MariaDB, and
    you haven't set the root password yet, the password will be blank,
    so you should just press enter here.
    
    Enter current password for root (enter for none):
    OK, successfully used password, moving on...
    
    Setting the root password ensures that nobody can log into the MariaDB
    root user without the proper authorisation.
    
    Set root password? [Y/n] y
    New password:
    Re-enter new password:
    Password updated successfully!
    Reloading privilege tables..
     ... Success!
    
    
    By default, a MariaDB installation has an anonymous user, allowing anyone
    to log into MariaDB without having to have a user account created for
    them.  This is intended only for testing, and to make the installation
    go a bit smoother.  You should remove them before moving into a
    production environment.
    
    Remove anonymous users? [Y/n] y
     ... Success!
    
    Normally, root should only be allowed to connect from 'localhost'.  This
    ensures that someone cannot guess at the root password from the network.
    
    Disallow root login remotely? [Y/n] y
     ... Success!
    
    By default, MariaDB comes with a database named 'test' that anyone can
    access.  This is also intended only for testing, and should be removed
    before moving into a production environment.
    
    Remove test database and access to it? [Y/n] y
     - Dropping test database...
     ... Success!
     - Removing privileges on test database...
     ... Success!
    
    Reloading the privilege tables will ensure that all changes made so far
    will take effect immediately.
    
    Reload privilege tables now? [Y/n] y
     ... Success!
    
    Cleaning up...
    
    All done!  If you've completed all of the above steps, your MariaDB
    installation should now be secure.
    
    Thanks for using MariaDB!
    

    配置UTF8编码

    1. 编辑/etc/my.cnf,在[mysqld]标签下添加如下内容
    default-storage-engine = innodb
    innodb_file_per_table
    max_connections = 4096
    collation-server = utf8_general_ci
    character-set-server = utf8
    
    1. 编辑/etc/my.cnf.d/client.cnf,在[client]标签下添加如下内容
    default-character-set=utf8
    
    1. 编辑/etc/my.cnf.d/mysql-clients.cnf,在[mysql]标签下添加如下内容
    default-character-set=utf8
    
    1. 重启服务
    systemctl stop mariadb
    systemctl start mariadb
    
    1. 验证结果
    show variables like 'character%'; 
    

    字符集

    忽略表名大小写

    编辑/etc/my.cnf,添加如下内容

    lower_case_table_name=1
    

    重启服务

    systemctl stop mariadb
    systemctl start mariadb
    

    验证结果

    show variables like "%lower_case_table_name"
    

    注意:
    若修改前已经存在表,修改后查询表时会出现“unknow database”错误,需要先导出后重建数据库。

    参考

    设置UTF8编码
    忽略表名大小写

  • 相关阅读:
    bzoj4810 [Ynoi2017]由乃的玉米田 bitset优化+暴力+莫队
    Ionic Js六:切换开关操作
    Ionic Js五:单选框操作
    Ionic Js四:复选框
    Ionic Js三:下拉刷新
    Ionic Js二:背景层
    Ionic Js一:上拉菜单(ActionSheet)
    Ionic入门十:icon(图标)
    Ionic入门九:颜色
    Ionic入门八:头部与底部
  • 原文地址:https://www.cnblogs.com/yingcheng/p/13640236.html
Copyright © 2011-2022 走看看