1. 程式人生 > 實用技巧 >CentOS安裝配置MariaDB - 筆記

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

配置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. 驗證結果

忽略表名大小寫

編輯/etc/my.cnf,新增如下內容

lower_case_table_name=1

重啟服務

systemctl stop mariadb
systemctl start mariadb

注意:
若修改前已經存在表,修改後查詢表時會出現“unknow database”錯誤。

參考

設定UTF8編碼


忽略表名大小寫