Linux通過(guò)Yum安裝MariaDB數(shù)據(jù)庫(kù)命令是什么
MariaDB數(shù)據(jù)庫(kù)管理系統(tǒng)是MySQL的一個(gè)分支,主要由開(kāi)源社區(qū)在維護(hù),采用GPL授權(quán)許可 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能輕松成為MySQL的代替品。有不少用戶不知道該如何安裝MariaDB數(shù)據(jù)庫(kù)。今天小編就和大家分享下yum 安裝 MariaDB 數(shù)據(jù)庫(kù)的方法。
Linux通過(guò)Yum安裝MariaDB數(shù)據(jù)庫(kù)的技巧
安裝方法:
準(zhǔn)備yum一個(gè)lamp環(huán)境,發(fā)現(xiàn)yum版本的mysql居然依然是5.1.x的版本,因此準(zhǔn)備更換為MariaDB。
配置源:
[root@localhost ~]# cat /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.0 CentOS repository list - created 2013-08-23 13:08 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
檢查源:
[root@localhost ~]# yum search mariadb
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.sjtu.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
======================================================= N/S Matched: mariadb ========================================================
MariaDB-Galera-server.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-Galera-test.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-cassandra-engine.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-client.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-common.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-compat.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-connect-engine.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-devel.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-oqgraph-engine.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-server.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-shared.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-test.x86_64 : MariaDB: a very fast and robust SQL database server
Name and summary matches only, use “search all” for everything.
安裝database:
[root@localhost ~]# yum install MariaDB-server MariaDB-client
[root@localhost ~]# yum install MariaDB-*
運(yùn)行database:
[root@localhost ~]# /etc/init.d/mysql start
Starting MySQL. SUCCESS!
[root@localhost ~]# mysql -V
mysql Ver 15.1 Distrib 10.0.17-MariaDB, for Linux (x86_64) using readline 5.1
補(bǔ)充:MySQL 數(shù)據(jù)庫(kù)常用命令
create database name; 創(chuàng)建數(shù)據(jù)庫(kù)
use databasename; 進(jìn)入數(shù)據(jù)庫(kù)
drop database name 直接刪除數(shù)據(jù)庫(kù),不提醒
show tables; 顯示表
describe tablename; 查看表的結(jié)構(gòu)
select 中加上distinct去除重復(fù)字段
mysqladmin drop databasename 刪除數(shù)據(jù)庫(kù)前,有提示。
顯示當(dāng)前mysql版本和當(dāng)前日期
select version(),current_date;
數(shù)據(jù)庫(kù)維護(hù)方法
在MySQL使用的過(guò)程中,在系統(tǒng)運(yùn)行一段時(shí)間后,可能會(huì)產(chǎn)生碎片,造成空間的浪費(fèi),所以有必要定期的對(duì)MySQL進(jìn)行碎片整理。
當(dāng)刪除id=2的記錄時(shí)候,發(fā)生的現(xiàn)象
這個(gè)時(shí)候發(fā)現(xiàn)磁盤(pán)的空間并沒(méi)有減少。這種現(xiàn)象就叫做碎片化(有一部分的磁盤(pán)空間在數(shù)據(jù)刪除以后(空),還是無(wú)法被操作系統(tǒng)所使用。)
常見(jiàn)的優(yōu)化:
# alter table xxx engine myisam;
# optimize table t1;
注意: 在實(shí)際開(kāi)發(fā)的過(guò)程中,上面兩個(gè)語(yǔ)句盡量少使用,因?yàn)樵谑褂玫倪^(guò)程中,MySQL的表的結(jié)構(gòu)會(huì)整體全部重新整理,需要消耗很多的資源,建議在凌晨?jī)扇c(diǎn)鐘的時(shí)候執(zhí)行。(在linux下有定時(shí)器腳本可以執(zhí)行,crontab)
數(shù)據(jù)庫(kù)相關(guān)文章:
1.怎么開(kāi)啟SQL數(shù)據(jù)庫(kù)服務(wù)
2.sql數(shù)據(jù)庫(kù)的集合函數(shù)查詢
3.excel怎么將表格連入數(shù)據(jù)庫(kù)