開發環境:
[root@burgess~]# yum grouplist
Installed Groups:………………….查看安裝此兩個包組,若沒有,則執行如下;
yumgroupinstall Development Tools
yumgroupinstall Server Platform Development
下載mariadb
網站下載:https://mariadb.org/
https://downloads.mariadb.org/mariadb/5.5.40/
http://mirrors.ustc.edu.cn/mariadb/mariadb-5.5.40/bintar-linux-x86_64/mariadb-5.5.40-linux-x86_64.tar.gz...................... stable General Available version
本地ftp下載
lftp ftp://172.16.0.1/pub/Sources/6.x86_64/mariadb
mget mariadb-5.5.36-linux-x86_64.tar.gz
解壓MariaDB Binary Tarballs,
[root@burgess ~]# tar xfmariadb-5.5.36-linux-x86_64.tar.gz -C /usr/local ……………………….展開至自定義目錄/usr/local
創建軟連接或更名(最好鏈接)
[root@burgess ~]# cd /usr/local
[root@burgess local]# ls
bin etc games include lib lib64 libexec mariadb-5.5.36-linux-x86_64 sbin share src
[root@burgess local]# lnmariadb-5.5.36-linux-x86_64 mysql -s
[root@burgess local]# ll ………..查看軟連接是否創建好;或者上一步直接用ln -sv 可直接查看
lrwxrwxrwx 1 root root 27 Dec 16 16:51 mysql-> mariadb-5.5.36-linux-x86_64
創建系統用戶
[root@burgess local]# groupadd -r mysql
[root@burgess local]# useradd -g mysql -rmysql
[root@burgess local]# id mysql ………………..查看用戶及組ID信息
uid=496(mysql)gid=493(mysql) groups=493(mysql)
[root@burgess local]# cd mysql
[root@burgess mysql]# pwd …………..查看當前路徑
/usr/local/mysql
創建邏輯卷(可選);
[root@burgess local]# mkdir /mydata
[root@burgess local]# fdisk /dev/sda
p:查看主分區
n:新建分區
p 新建主分區
3 編號
+30G 添加分區大小
T ….爲新加分區修改Td
3 指定分區編號
8e …………Td
P 查看Td是否生效
w:保存退出
[root@burgess mysql]# partx-a /dev/sda …………..讓內核識別新分區
[root@burgess mysql]#pvcreate /dev/sda3
[root@burgess mysql]#vgcreate myvg/dev/sda3
[root@burgess mysql]#lvcreate-L 10G -n mylv myvg
創建文件系統;…..xfs (若沒有)
[root@burgess mysql]#yum list all | grepxfs
[root@burgess mysql]#yum -y installxfsprogs
[root@burgess mysql]#mkfs -t xfs /dev/myvg/mylv
[root@burgess mysql]#vim /etc/fstab ………………..掛載至mydata(作用爲邏輯卷增加大小的時候,不受影響)
/dev/myvg/mylv /mydata xfs defaults 0 0
[root@burgess mysql]#mount -a
[root@burgess mysql]#mount ………………查看是否掛載上
創建/mydata/data :(因爲mydata是在根下的,不在新分區上 ,所以掛載的文件會散裝在新分區,不利於管理)
[root@burgess mysql]#mkdir /mydata/data
[root@burgess mysql]#chown -R mysql:mysql/mydata/data/
[root@burgess mysql]#ll /mydata
[root@burgess mysql]#pwd
[root@burgess mysql]#ll
Mariadb數據初始化;
[root@burgess mysql]#scripts/mysql_install_db--help (重要選項釋義)
--datadir=path The path to the MariaDB data directory. ……………………………………..數據目錄存放位置
--defaults-extra-file=name
Read this file after theglobal files are read. …………………………………讀取全局配置文件位置
--skip-name-resolve Use IP addresses rather than hostnames whencreating ……………………….跳過主機名解析
grant tableentries. This option can be useful if
your DNS does not work.
--user=user_name The login username to use for runningmysqld. Files ………………………………以哪個用戶完成初始化
and directories createdby mysqld will be owned by this
user. You must be root to use this option. By default
mysqld runs using yourcurrent login name and files and
directories that itcreates will be owned by you.
[root@burgess mysql]#scripts/mysql_install_db--user=mysql --datadir=/mydata/data
[root@burgess mysql]# ls /mydata/data
aria_log.00000001 aria_log_control mysql performance_schema test
[root@burgess mysql]# ls
bin COPYING.LESSER docs INSTALL-BINARY man README share support-files
COPYING data include lib mysql-test scripts sql-bench
[root@burgess mysql]# mkdir /etc/mysql
[root@burgess mysql]# cpsupport-files/my-large.cnf /etc/mysql/my.cnf
[root@burgess mysql]#vim /etc/mysql/my.cnf
datadir=/mydata/data
innodb_file_per_table=on ……………要修改的內容 =1也可以
[root@burgess mysql]#ls
[root@burgess mysql]#cp support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@burgess mysql]# chkconfig --listmysqld
service mysqld supports chkconfig, but is not referenced in anyrunlevel (run 'chkconfig --add mysqld')
[root@burgess mysql]# chkconfig --addmysqld ……………………..加載至開機啓動項,但目前還沒有啓動,只能下次生效啓動
[root@burgess mysql]# chkconfig --listmysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@burgess mysql]# service mysqldstart ………………….手動啓動
Starting MySQL... [ OK ] ls /mydata/data
[root@burgess mysql]# vim /etc/profile.d/mariadb.sh
export PATH=/usr/local/mysql/bin:$PATH
[root@burgess mysql]#./etc/profile.d/mariadb.sh
[root@burgess mysql]# Echo $PATH
[root@burgess mysql]# mysql ……………….啓用之 ,則接口完成了
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.36-MariaDB-log MariaDB Server
Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the currentinput statement.
MariaDB [(none)]>
更多詳細內容參考官網https://mariadb.com/kb/en/mariadb/documentation/getting-started/binary-packages/installing-mariadb-binary-tarballs/