1.mariadb的安裝php
配置yum倉庫,安裝mariadbhtml
Mariadb使用的端口默認狀況下是開放的,這樣對數據庫來講一定是不安全的,因此咱們須要關閉端口,編輯/etc/my.cnf文件,在[mysqld]中加入如下參數:skip-networking=1mysql
systemctl start mariadblinux
2.數據庫安全初始化sql
@@數據庫原始密碼,默認沒有,直接回車數據庫
@@是否設定超級用戶密碼,默認爲是,而後設定密碼,再次確認密碼瀏覽器
@@是否刪除匿名用戶訪問權限,默認爲是安全
@@是否禁止超級用戶經過遠程登陸,默認爲是ide
@@是否刷新數據庫,默認爲是測試
@@從新加載數據庫,默認爲是
3.數據庫的使用
登陸
mysql -uroot -pwestos ##-u表示指定登錄用戶,-p 表示指定此用戶密碼
@@登陸時,也可在-p後加上密碼,可是這樣會有回顯,別人也會看到超級用戶密碼,不建議這樣作
查詢
show databases; ##顯示數據庫
use mysql; ##進入mysql庫
select * from user; ##查詢user表中的全部內容(*能夠用此表中的任何字段來代替)
select * from user where Host=‘127.0.0.1’;
##查詢user表中在127.0.0.1這個段的內容
數據庫及表的創建
create database westos;
create table linux(
username varchar(20) not null, ##20個字符長度且不能爲空
password varchar(20) not null ##20個字符長度且不能爲空
age varchar(10) ##10個字符長度,能夠爲空
);
insert into linux values ('user1','passwd1','age'); ##填充表格
數據庫的修改
alter table linux add weight varchar(30) after passwd; ##在passwd後增長weight列
update linux set weight='70' where username='lee'; ##把weight列lee的信息更新爲70
update linux set mariadb='45' where username='mariadb'; ##把weight列中mariadb的信息更新爲45
alter table linux drop weight; ##刪除weight列
刪除數據
delete from linux where username='user1'; ##刪除user1的數據從linux表中
drop table linux; ##刪除linux表
drop database westos; ##刪除westos庫
數據庫備份
mysqldump -u root -pwestos --all-database ##備份全部表中的左右數據
mysqldump -u root -pwestos --all-database --no-data ##備份全部表,但不備份數據
mysqldump -u root -pwestos westos ##備份westos庫
mysqldump -u root -pwestos westos > /mnt/westos.sql ##備份westos庫並把數據保存到westos.sql中
而後刪除westos這個庫
mysql -uroot -pwestos -e "create database westos;" ##創建westos庫
mysql -uroot -pwestos westos < /mnt/westos.sql ##把數據導入westos庫
數據庫密碼修改
mysqladmin -uroot -pwestos password lee ##修該超級用戶密碼
mysqld_safe --skip-grant-tables & ##開啓mysql登錄接口並忽略受權表
update mysql.user set Password=password('123') where User='root'; ##更新超級用戶密碼信息
ps aux | grep mysql ##過濾mysql的全部進程並結束這些進程
kill -9 mysqlpid
systemctl start mariadb ##從新啓動數據庫
數據庫的網頁管理
yum install httpd php php-mysql -y ##安裝phpmyadmin包
systemctl start httpd ##開啓http服務
systemctl enable httpd
systemctl stop firewalld ##關閉火牆
systemctl disable firewalld
獲取phpMyAdmin將他放在http的默認發佈目錄/var/www/html下,而後將壓縮包解壓,並重命名爲mysqladmin,方便後續操做。
安裝 yum install httpd php php-mysql -y
開啓http、php等服務
測試
打開一個瀏覽器,在瀏覽器搜索行輸入http://172.25.254.125/mysqladmin(這個根據你本身的主機ip進行訪問)
@@輸入用戶名及密碼後看到的頁面,在這個頁面上你能夠進行經常使用編輯,開啓圖形界面編輯後,能夠看到相應的sql語句(紫色字體部分就是sql語句)