安裝MariaDB

1、安裝MariaDB

安裝命令

yum -y install mariadb mariadb-server
安裝完成MariaDB,首先啟動MariaDB

systemctl start mariadb
設置開機啟動

systemctl enable mariadb
接下來進行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] <– 是否重新加載權限表,回車

初始化MariaDB完成,接下來測試登錄

mysql -uroot -ppassword
完成。

 

2、配置MariaDB的字符集

文件/etc/my.cnf

vi /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
文件/etc/my.cnf.d/client.cnf

vi /etc/my.cnf.d/client.cnf
在[client]中添加

default-character-set=utf8
文件/etc/my.cnf.d/mysql-clients.cnf

vi /etc/my.cnf.d/mysql-clients.cnf
在[mysql]中添加

default-character-set=utf8
 全部配置完成,重啟mariadb

systemctl restart mariadb
之后進入MariaDB查看字符集

mysql> 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)

字符集配置完成。

 

3、添加用戶,設置權限

創建用戶命令

mysql>create user username@localhost identified by ‘password’;
直接創建用戶并授權的命令

mysql>grant all on . to username@localhost indentified by ‘password’;
授予外網登陸權限 

mysql>grant all privileges on . to username@’%’ identified by ‘password’;
授予權限并且可以授權

mysql>grant all privileges on . to username@’hostname’ identified by ‘password’ with grant option;
簡單的用戶和權限配置基本就這樣了。

其中只授予部分權限把 其中 all privileges或者all改為

select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file其中一部分。

原創文章,作者:sunhao,如若轉載,請注明出處:http://www.www58058.com/84174

(0)
sunhaosunhao
上一篇 2017-08-07
下一篇 2017-08-08

相關推薦

  • 字符串切片和yum的用法和rpm的編譯安裝

    1、冒泡法對數組內數據排序 2、源碼安裝http2.2.29     1.配置/etc/yum.repos.d/base.repo              2.安裝group組:Development too…

    Linux干貨 2016-08-30
  • shell編程之條件判斷和find查詢

    使用read 來把輸入值分配給一個或多個shell 變量: -p 指定要顯示的提示 -t TIMEOUT read 從標準輸入中讀取值,給每個單詞分配一個變量 所有剩余單詞都被分配給最后一個變量 read -p “Enter a filename: “ FILE   條件選擇if語句  多分支 if  CONDITION1 ; …

    Linux干貨 2016-08-18
  • inode的理解

    一、inode是什么 理解inode,要從文件儲存說起。 文件儲存在硬盤上,硬盤的最小存儲單位叫做"扇區"(Sector)。每個扇區儲存512字節(相當于0.5KB)。 操作系統讀取硬盤的時候,不會一個個扇區地讀取,這樣效率太低,而是一次性連續讀取多個扇區,即一次性讀取一個"塊"(block)。這種由多個扇區組成的&q…

    Linux干貨 2017-01-16
  • 數組知識與編譯安裝

    數組知識與編譯安裝 一數組知識 1、定義數組    聲明數組: declare -a ARRAY_NAME declare -A ARRAY_NAME:  關聯數組 數組元素的賦值: (1)  一次只賦值一個元素; ARRAY_NAME[INDEX]=VALUE weekdays[0]="Sunday&quo…

    Linux干貨 2016-09-19
  • ?yum源的生成與配置{ local;cdrom;http;ftp;}

    ?yum源的生成與配置{ local;cdrom;http;ftp;} 本文是繼上一篇文章“CentOS程序安裝的3種方式{ 源碼包安裝 | rpm包安裝 | yum安裝;}”的補充,上篇文章http://www.www58058.com/38812主要介紹了基于cdrom的yum源制作和配置以及歸納了詳細的yum命令。本文繼續介紹基于本地file、遠程ht…

    Linux干貨 2016-08-24
  • linux中for的用法

    關于linuxbash shell中的for語句 在linux中shell是必不可少的一部分,但是在bash shell中有while,for,until等循環命令,今天就介紹一下關于for的一些用法。文中任何錯誤希望大佬們一一指出,不勝感激。 bashshell中提供了for命令,用于創建通過一系列值重復的循環,每次重復使用系列中的一個值執行一個定義的命令…

    2017-07-15
欧美性久久久久