資料庫服務基礎
常見的關系型,資料庫管理系統。
1.微軟的SQL Server
2.IBM的DB2
3.甲骨文的Oracle MySQL
4.社群開源版mariaDB
5.RHEL7中的MariaDB相關包
mariadb-server 提供服務端有關的系統程式
端口号:3306
一、部署mariadb資料庫
1.安裝mariadb-server資料庫軟體
yum -y install mariadb-server
2..資料庫主配置檔案路徑/etc/my.cnf
3.啟動mariadb服務
4.指令
mysql 進入資料庫
show databases; 檢視資料庫
create database abc; 建立資料庫
drop database abc; 删除資料庫
use 資料庫名; 使用/選擇資料庫
show tables; 列出資料庫的表格
quit 退出資料庫
資料庫管理者為root,但是與系統使用者root沒有任何關系。
為資料庫賬号添加/修改密碼:
格式: mysqladmin -u 使用者名 -p密碼 password ‘新密碼’
例: mysqladmin -u root password '456' (建立密碼)
mysqladmin -u root -p456 password '123'(修改密碼)
mysql -u root -p123 (免互動登入)
禁止監聽,隻服務于本機的設定。
vim /etc/my.cnf 資料庫主配置檔案
skip-networking 跳過網絡監聽
systemctl restart mariadb 重新開機服務
導入/恢複到資料庫
mysql -u 使用者名 -P密碼 資料庫名 < 備份檔案.sql
查詢操作:
select * from base;
select * from location;
select id,name from base;
例: mysqkl -u root -p123 (進入資料庫)
use abc;
select * from base where name='tom';(查詢人名)
select * from location where city='beijing';(查詢城市)
資料庫授權
格式:grant 權限 on 資料庫名.表名 to 使用者@localhost
indentified by '密碼';
例: grant select on abc.* lisi@localhost indentified by '123';
當使用者lisi從本地localhost登入,輸入密碼123,将會獲得庫abc所有表的查詢權限。
本文轉自夜流璃雨 51CTO部落格,原文連結:http://blog.51cto.com/13399294/1983642,如需轉載請自行聯系原作者