溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

linux中如何實(shí)現(xiàn)數(shù)據(jù)庫管理

發(fā)布時間:2021-11-25 10:40:28 來源:億速云 閱讀:149 作者:小新 欄目:數(shù)據(jù)庫

這篇文章主要介紹了linux中如何實(shí)現(xiàn)數(shù)據(jù)庫管理,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。

數(shù)據(jù)庫管理

yum install mariadb -y/*安裝數(shù)據(jù)庫及數(shù)據(jù)庫服務(wù)

yum install mariadb-server -y

vim /etc/my.cnf

skip-networking=1/*禁止遠(yuǎn)程訪問數(shù)據(jù)庫

mysql_secure_installation/*建立數(shù)據(jù)庫登錄密碼以及安全訪問設(shè)置

systemctl restart mariadb

mysql -uroot -pwestos/*從本地登錄mysql數(shù)據(jù)庫

show databases/*顯示數(shù)據(jù)庫

use mysql/*進(jìn)入數(shù)據(jù)庫

select * from user/*顯示所有用戶的信息

show tables/*顯示數(shù)據(jù)庫中的表

desc user/*查看user表的數(shù)據(jù)結(jié)構(gòu)

flush privileges/*刷新數(shù)據(jù)庫信息

select host,user,password form user;/*查詢user表中的host,user,password字段

create database westos;/*創(chuàng)建westos數(shù)據(jù)庫

use westos;/*使用westos數(shù)據(jù)庫

create table linux(username varchar(15) not null,password varchar(15) not null;age varchar(10));

insert into linux values ('lee','123','18');/*創(chuàng)建username,password,age字段

select * from mysql.user; /*查詢mysql庫下的user表中的所有

alter table linux add age varchar(5) /*添加age字段到linux表中

alter table linux drop age/*刪除age字段在linux表中

alter table linux add age varchar(4) after name;/*在password后面添加age字段到linux表中

alter table westos add class varchar(4) after password;/*在password后面添加class字段到linux表中

update westos set class='2' where username='westos';/*重新更新class=2在westos

delete from westos where username='westos';/*刪除westos

drop table linux/*刪除linux表格

drop database westos/*刪除westos數(shù)據(jù)庫

CREATE USER westos@localhost identified by 'westos';/*創(chuàng)建用戶

GRANT INSERT on *.* to westos@locsalhost;/*用戶授權(quán)

FLUSH PRIVILEGES;/*重載授權(quán)表

SHOW GRANTS FOR westos@localhost;/*查看用戶授權(quán)

REVOKE create on *.* from westos@localhost;/*撤銷用戶權(quán)限

DROP USER westos@localhost;/*刪除用戶

備份

 mysqldump -uroot -predhat westos > westos.dump

 mysqldump -uroot -predhat --all-databases > backup.dump

 mysqldump -uroot -predhat --no-data westos > westos.dump

恢復(fù)

 mysqladmin -uroot -predhat create db2

 mysql -uroot -predhat db2 < westos.dump

忘了數(shù)據(jù)庫密碼

 systemctl stop mariadb

 mysqld_safe --skip-grant-tables &/*打斷密碼初始化

 update mysql.user set Password=('redhat') where User='root';/*修改密碼

 killall -9 mysqld_safe/*殺死所有mysql的進(jìn)程

 ps aux | grep mysql

 kill -9 pid

systemctl start mariadb

mysqladmin -uroot -pwestos password redhat/*常規(guī)修改密碼的方式

通過軟件管理數(shù)據(jù)庫

yum install httpd  php  php-mysql  -y

tar jxf phpadmin.tar.bz2 -C /var/www/html /*解壓phpadmin到/var/www/html/,通過httpd共享

cp -p config.sample.inc.php config.inc.php/*配置文件,添加cookie名字

http://ip/目錄

感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享的“l(fā)inux中如何實(shí)現(xiàn)數(shù)據(jù)庫管理”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關(guān)注億速云行業(yè)資訊頻道,更多相關(guān)知識等著你來學(xué)習(xí)!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI