久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

常用的MySQL命令有哪些

133次閱讀
沒有評論

共計 1558 個字符,預計需要花費 4 分鐘才能閱讀完成。

自動寫代碼機器人,免費開通

這篇文章主要介紹常用的 MySQL 命令有哪些,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!

在日常的網站維護和管理中,會用到非常多的 SQL 語句,
熟練使用對網站管理有很多好處,尤其是站群管理的時候。

下面列一些常用的命令做備記。

1、顯示數據庫
show databases
顯示表
show tables;

2、創建用戶
創建 root 用戶密碼為 123

use mysql; 
grant all on *.* to root@ %  identified by  123  with grant option; 
commit;

3、修改密碼

grant all on *.* to xing@ localhost  identified by  123456  with grant option; 
update user set password = password(newpwd) where user =  xing  and host= localhost  
flush privileges;

4、創建數據庫 testdb:

create database testdb;

5、預防性創建數據庫:

create database if not testdb;

6、創建表:

use testdb; 
create table table1( 
username varchar(12), 
password varchar(20));

7、預防性創建表 aaa:

create table if not exists aaa(ss varchar(20));

8、查看表結構:

describe table1;

9、插入數據到表 table1:

insert into table1(username,password) values 
(leizhimin , lavasoft), 
( hellokitty , hahhahah  
commit;

10、查詢表 table1:

select * from table1;

11、更改數據:

update table1 set password= hehe  where username= hellokitty  
commit;

12、刪除數據:

delete from table1 where username= hellokitty  
commit;

13、給表添加一列:

alter table table1 add column( 
 sex varchar(2) comment  性別 , 
 age date not null comment  年齡  
); 
commit;

14、修改表結構

從查詢創建一個表 table1:

create table tmp as 
select * from table1;

15、刪除表 table1:

drop table if exists table1; 
drop table if exists tmp;

16、備份數據庫 testdb

mysqldump -h 192.168.3.143 -u root -p pwd -x --default-character-set=gbk  C:\testdb.sql

17、刪除數據庫 testdb

drop database testdb;

18、恢復 testdb 數據庫
首先先建立 testdb 數據庫,然后用下面命令進行本地恢復

mysql -u root -pleizhimin testdb  C:\testdb.sql

這 18 個 MYSQL 命令都是管理員在日常維護中經常會用到的,熟練使用這些命令會使你的工作非

以上是“常用的 MySQL 命令有哪些”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注丸趣 TV 行業資訊頻道!

向 AI 問一下細節

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-12-16發表,共計1558字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 余江县| 买车| 淅川县| 平阳县| 班玛县| 江华| 屯留县| 九台市| 旬阳县| 大新县| 东源县| 大竹县| 濮阳县| 南澳县| 辽中县| 江北区| 璧山县| 池州市| 册亨县| 亳州市| 溧阳市| 平远县| 合水县| 蕉岭县| 弥勒县| 乌拉特中旗| 遵化市| 汾阳市| 晋州市| 辛集市| 阿城市| 大连市| 灯塔市| 古浪县| 桂林市| 原平市| 中卫市| 万山特区| 木兰县| 阜平县| 拉萨市|