MySQL常用命令收集

來源:互聯網
上載者:User

標籤:des   style   blog   http   ar   color   os   sp   檔案   

轉載自:http://www.educity.cn/wenda/400530.html

1.連結MySQL資料庫

  格式:mysql -h網域名稱 -u使用者名稱 -p密碼 資料庫名字

  1.1 首先開啟DOS視窗,然後進入目錄mysql\bin,再鍵入命令mysql -uroot -p,斷行符號後提示你輸密碼.注意使用者名稱前可以有空格也可以沒有空格,如果剛安裝好MYSQL,沒有設定密碼時,超級使用者root是沒有密碼的,故直接斷行符號即可進入到MYSQL中了,MYSQL的提示符是: mysql>

  1.2 退出MySQL命令:exit

2.修改密碼  

  格式:mysqladmin -u使用者名稱 -p舊密碼 password 新密碼

3.顯示當前資料庫伺服器中的資料庫列表:

  mysql> show databases;

4.顯示資料庫中的資料表:

  mysql> use 資料庫名;

  mysql> show tables;

5.顯示資料表的結構:

  mysql> describe 表名;

6.建立資料庫:

  mysql> create database 資料庫名;

7.建立資料表:

  mysql> use 資料庫名;

  mysql> create table 表名 (欄位名 varchar(20), 欄位名 char(1));

8.刪除資料庫:

  mysql> drop database 資料庫名;

9.刪除資料表:

  mysql> drop table 表名;

10.將表中記錄清空:

  mysql> delete from 表名;

11.顯示表中的記錄:

  mysql> select * from 表名;

12.往表中插入記錄:

  mysql> insert into 表名 values (”hyq”,”M”);

13.更新表中資料:

  mysql-> update 表名 set 欄位名1=’a‘,欄位名2=’b’ where 欄位名3=’c‘;

14.用文本方式將資料裝入資料表中:

  mysql> load data local infile “D:/mysql.txt” INTO TABLE 表名;

15.匯入.sql檔案命令:

  mysql> use 資料庫名;

  mysql> source d:/mysql.sql;

16.命令列修改root密碼:

  mysql> update mysql.user set password=password(’新密碼’) where user=’root’;

  mysql> flush privileges;

17.顯示use的資料庫名:

  mysql> select database();

18.顯示當前的user:

  mysql> select user();

 

注意:每個命令後面都要以;結尾。mysql允許換行輸入命令,命令與命令之間用;隔開。此處留意,否則......

MySQL常用命令收集

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.