日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

命令行操作mysql

發(fā)布時(shí)間:2023/12/4 数据库 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 命令行操作mysql 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1、通過命令行連接mysql:
1、輸入命令:mysql -h localhost(服務(wù)IP地址) -u root(用戶名) -P 3306(服務(wù)端口)-p
2、輸入密碼

2、顯示數(shù)據(jù)庫、表:

show databases; //顯示存在的數(shù)據(jù)庫 use test; //test為相對(duì)應(yīng)的數(shù)據(jù)庫名稱,表示使用某個(gè)數(shù)據(jù)庫 show tables; //顯示此數(shù)據(jù)庫的所有表

3、命令行查詢表結(jié)構(gòu)

1desc tabl_name;(查詢表結(jié)構(gòu)信息) 2select * from information_schema.columns where table_schema = 'db' #表所在數(shù)據(jù)庫 and table_name = 'tablename' ; #你要查的表(查詢表結(jié)構(gòu)信息) 3select column_name, column_comment from information_schema.columns where table_schema ='db' and table_name = 'tablename' ;(只查詢列名、注釋信息) 4select table_name,table_comment from information_schema.tables where table_schema = 'db' and table_name ='tablename'(查看表的注釋)

4、執(zhí)行增刪改查:

create database test; //建數(shù)據(jù)庫。名字為test create table user(id int(4) not null primary key auto_increment,username char(20)not null,password char(20) not null);//創(chuàng)建數(shù)據(jù)庫,名為userinsert into user (1,'duoduo','921012'); //插入一條數(shù)據(jù)select * from user; //查詢所有的信息

5、用戶授權(quán):

grant select on *.* to 'reader'@'%' identified by '123456' WITH GRANT OPTION flush privileges

總結(jié)

以上是生活随笔為你收集整理的命令行操作mysql的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。