欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

mysql常用操作命令

###########MySQL常用操作命令#############

1.安裝mysql
yum install mysql mysql-server
 /etc/init.d/mysqld start    ##開啟mysqld服務(wù)

2.設(shè)置及登錄
mysql_secure_installation        ##第一次安裝mysql以后通過這條命令可以對mysql進(jìn)行初始設(shè)置
mysql -uroot -predhat            ##從本機(jī)登錄mysql數(shù)據(jù)庫(ps -aux|grep mysql  kill -9 )
mysqladmin -uroot -predhat password westos         ##修改本地mysql,root密碼
mysqladmin -uroot -predhat -h 172.25.8.1 password westos ##修改遠(yuǎn)程172.25.8.1mysql服務(wù)器,root密碼

3.操作命令
庫操作:
show databases;                ##顯示數(shù)據(jù)庫
use mysql;                    ##進(jìn)入數(shù)據(jù)庫(按回車鍵出現(xiàn)Database changed時(shí)說明操作成功!)
show tables;                ##顯示數(shù)據(jù)庫中的表
desc user;                    ##查看user表的結(jié)構(gòu)
flush privileges;            ##刷新數(shù)據(jù)庫信息
select host,user,password from user;    ##查詢user表中的host,user,password字段
create database westos;                    ##創(chuàng)建westos數(shù)據(jù)庫
use westos;                        ##進(jìn)入數(shù)據(jù)庫westos

表操作:
create table linux(            ##創(chuàng)建表,表名linux,字段username,password
username varchar(15) not null,
password varchar(15) not null);

成都創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供焉耆網(wǎng)站建設(shè)、焉耆做網(wǎng)站、焉耆網(wǎng)站設(shè)計(jì)、焉耆網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)與制作、焉耆企業(yè)網(wǎng)站模板建站服務(wù),十余年焉耆做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。

select * from mysql.user;        ##查詢mysql庫下的user表中的所有內(nèi)容

alter table linux add age varchar(4);    ##添加age字段到linux表中

desc linux;                ##查看linux表結(jié)構(gòu)

ALTER TABLE linux DROP age        ##刪除linux表中的age字段

ALTER TABLE linux ADD age  VARCHAR(4)  AFTER username ##在linux表username字段后添加字段age

desc linux;                ##查看linux表結(jié)構(gòu)

insert into linux values ('user1',18,'passwd1'); ##在linux表中插入username=user1,age=18,password=password1
update linux set password='passwd2' where username="user1";    ##更新linux表中user1的密碼為password2
delete from linux where username='user1';         ##刪除linux表中user1的所有內(nèi)容
select * from linux;   ##可以進(jìn)行查看

用戶管理:
CREATE USER hjy@localhost identified by 'westos';    ##創(chuàng)建本地用戶hjy并添加密碼westos,默認(rèn)密碼是加密的
CREATE USER hee@'%' identified by 'redhat';        ##創(chuàng)建用戶hee,%表示這個(gè)賬戶可以在任何主機(jī)登錄
select host,User,Password from user;            ##查詢user表中的host,user,password字段

grant select on  *.* to user1@localhost identified by 'passwd1'; ##授權(quán)user1,密碼為passwd1,并且只能在本地查詢數(shù)據(jù)庫的所在內(nèi)容
grant all on mysql.* to user2@'%' identified by 'passwd2';     ##授權(quán)user2,密碼為passwd2,可以從遠(yuǎn)程任意主機(jī)登錄mysql并且可以對mysql數(shù)據(jù)庫任意操作(%改為ip可指定此ip登錄)

FLUSH PRIVILEGES;                        ##重載授權(quán)表
SHOW GRANTS FOR hjy@localhost;                    ##查看用戶授權(quán)
REVOKE DELETE,UPDATE,INSERT on mysql.* from hjy@localhost;    ##撤銷用戶對mysql的DELETE,UPDATE,INSERT權(quán)限
REVOKE all on mysql.* from hjy@localhost;            ##撤銷用戶所有權(quán)限
DROP USER hjy@localhost;                    ##刪除用戶


備份
/var/lib/mysql
mysqldump -uroot -predhat --all-databases    ##命令備份所有數(shù)據(jù)
mysqldump -uroot -predhat mysql > mysql.bak    ##備份mysql庫導(dǎo)到mysql.bak
mysql -uroot -predhat -e "create database westos;"  ##創(chuàng)建一個(gè)數(shù)據(jù)庫
mysql -uroot -predhat westos < mysql.bak    ##恢復(fù)mysql.bak到westos庫

密碼恢復(fù)
/etc/init.d/mysqld stop
mysqld_safe --skip-grant-tables &          ##跳過grant-tables授權(quán)表,不需要認(rèn)證登錄本地mysql數(shù)據(jù)庫
update mysql.user set password=password('westos') where user='root';    ##更新mysql.user表中條件root用戶的密碼為westos
/etc/init.d/mysql restart    ##重新啟動(dòng)nysql

當(dāng)前標(biāo)題:mysql常用操作命令
當(dāng)前路徑:http://chinadenli.net/article8/pighip.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)營銷型網(wǎng)站建設(shè)用戶體驗(yàn)外貿(mào)網(wǎng)站建設(shè)響應(yīng)式網(wǎng)站面包屑導(dǎo)航

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

手機(jī)網(wǎng)站建設(shè)