mysql資料庫相關操作(持續更新)

2021-08-18 00:17:48 字數 683 閱讀 9227

mysqldump -u使用者名稱 -p密碼 -h mysql主機  --default-character-set=指定編碼  資料庫名稱  表名稱  --where=" 查詢條件 " > 匯出檔名.sql

例:mysqldump -uroot -p123456 -h 127.0.0.1 --default-character-set=utf8 mydb mytable -- where="name="test" and id = 1" > myexport.sql

兩種方式:

(1)mysql -u使用者名稱 -p密碼 -d資料庫名<.sql檔案

例:mysql -uroot -p123456 -dmydb < export.sql

(2)進入到mysql控制台

mysql -u使用者名稱 -p密碼

use 資料庫名

source .sql檔案

進入命令列:

mysql -u使用者名稱 -p密碼 -h 伺服器ip位址 -p 伺服器端mysql埠號 -d 資料庫名

注:使用者名稱和-u、密碼和-p之間沒有空格,-h,-p和後面的字元有空格

4、基本操作

(1)顯示資料庫列表:

show databases;

(2)顯示資料庫中的表:

show tables;

(3)顯示表的結構:

desc 表名;

Mysql資料庫相關操作

檢視約束 show indexes from tab name 檢視索引 show index from tab name 檢視資料表的列 show columns from tab name 檢視資料表 show tables 檢視資料庫 show databases 刪除列alter table...

MySQL資料庫操作相關

1 mysql資料庫設定自增序號,刪除表中資料序號錯亂重新排序 alter table tablename drop column id alter table tablename add id mediumint 8 not null primary key auto increment firs...

MySQL資料庫相關操作

mysql是乙個關係型資料庫管理系統,目前屬於oracle。採用sql標準化語言,並且體積小 速度快 成本低和開源的特點,搭配php apache可組成良好的開發環境。create table t user id int primary key auto increament comment 自增主...