centos 7 系統下mariadb的安裝及簡單配置


mariadb的安裝

1.yum  list | grep  mariadb     <--查看系統中自帶的數據庫版本號

2.yum -y install mariadb*       <--安裝數據庫及所需要的依賴環境

3.systemctl  start  mariadb     <--啟動數據庫服務

4.systemctl  enable  mariadb    <--設置開機自動啟動數據庫

5.mysql_secure_installation       <--進行數據庫的相關配置

Enter current password for root(Enter and none):     <--初次直接按回車

New Password:                            <--設置密碼

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]                         <--是否加載權限表      直接回車

初始化完Maraidb數據庫,接下來進入登錄測試

mysql   -uroot  -p +密碼                                           <--登錄數據庫

 

配置Mariadb的字符集

1. 文件 /etc/my.cnf

vim /etc/my.cnf

在[mysql]標簽下添加

init_connect = 'SET collection_connection = utf8_unicode_ci' 

init_connect = 'SET NAMES utf8'

character-set-server = utf8

collection-server = utf8-unicode-ci

skip-character-set-client-handshake

2.文件/etc/my.cnf.d/client.cnf

vim   /etc/my.cnf.d/client.cnf

在[client]標簽下添加

default-character-set = utf8

配置完成,重新啟動mariadb

systemctl  restart mariadb 

之后進入數據庫,查看字符集

mysql>show variables like "%character%";show variables like "%collection%";

創建utf8編碼的庫:

CREATE DATABASE db_name DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM