mysql command line client 使用命令,mysqlclient

來源:互聯網
上載者:User

mysql command line client 使用命令,mysqlclient
1.輸入密碼:******
2.ues mysql;使用Mysql
3.show databases;顯示資料庫
4.use register;使用資料庫名為register
5.show tables;顯示register資料庫中的表
6.describe user;對錶user進行操作:

insert into user(username,password) values("xiaoyan","123456");插入資料
insert into user(username,password) values("ff","123456");插入資料
delete from user where username="xiaoyan";刪除資料
update user set username="xiaoyan" where username="ff";更新資料
select * from user;查詢資料

7.quit;推出
1、顯示當前資料庫伺服器中的資料庫列表:
mysql> SHOW DATABASES;
注意:mysql庫裡面有MYSQL的系統資訊,我們改密碼和新增使用者,實際上就是用這個庫進行操作。
2、顯示資料庫中的資料表:
mysql> USE 庫名;
mysql> SHOW TABLES;
3、顯示資料表的結構:
mysql> DESCRIBE 表名;
4、建立資料庫:
mysql> CREATE DATABASE 庫名;
5、建立資料表:
mysql> USE 庫名;
mysql> CREATE TABLE 表名 (欄位名 VARCHAR(20), 欄位名 CHAR(1));
6、刪除資料庫:
mysql> DROP DATABASE 庫名;
7、刪除資料表:
mysql> DROP TABLE 表名;
8、將表中記錄清空:
mysql> DELETE FROM 表名;
9、顯示表中的記錄:
mysql> SELECT * FROM 表名;
10、往表中插入記錄:
mysql> INSERT INTO 表名 VALUES (”hyq”,”M”);
11、更新表中資料:
mysql-> UPDATE 表名 SET 欄位名 1=’a',欄位名2=’b’ WHERE 欄位名3=’c';
12、用文本方式將資料裝入資料表中:
mysql> LOAD DATA LOCAL INFILE “D:/mysql.txt” INTO TABLE 表名;
13、匯入.sql檔案命令:
mysql> USE 資料庫名;
mysql> SOURCE d:/mysql.sql;
14、命令列修改root密碼:
mysql> UPDATE mysql.user SET password=PASSWORD(’新密碼’) WHERE User=’root’;
mysql> FLUSH PRIVILEGES;
15、顯示use的資料庫名:
mysql> SELECT DATABASE();
16、顯示當前的user:
mysql> SELECT USER();
 

相關文章

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.