您好,登錄后才能下訂單哦!
1,Linux下安裝完后root密碼為空,使用以下命令創(chuàng)建密碼
[root@host]# mysqladmin -u root password "new_password";
2,連接到MySQL服務器
[root@host]# mysql -u root -p
Enter password:*******
3,退出quit或exit
[root@host]# quit
[root@host]# exit
1,查看所有數(shù)據(jù)庫
[root@host]# show databases;
2,創(chuàng)建數(shù)據(jù)庫
[root@host]# create database 數(shù)據(jù)庫名 charset utf8;
3,刪除數(shù)據(jù)庫
[root@host]# drop database 數(shù)據(jù)庫名;
4,切換數(shù)據(jù)庫
[root@host]# use 數(shù)據(jù)庫名;
5,查看正在使用的數(shù)據(jù)庫
[root@host]# select database();
1,查看數(shù)據(jù)庫中所有表
[root@host]# show tables;
2,創(chuàng)建表
[root@host]# create table 表名(列 類型);
Example
[root@host]# create table student(
id int auto_increment primary key,
name varchar(20) not null,
gender tinyint not null,
address varchar(40),
isDelete tinyint default 0
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
3,刪除表
[root@host]# drop table 表名;
4,查看表結(jié)構(gòu)
[root@host]# desc 表名;
1,插入數(shù)據(jù)
INSERT INTO table_name ( field1, field2,...fieldN )
VALUES
( value1, value2,...valueN );
2,where語句
SELECT field1, field2,...fieldN FROM table_name1, table_name2...
[WHERE condition1 [AND [OR]] condition2.....
3,查詢數(shù)據(jù)
SELECT column_name,column_name
FROM table_name
[WHERE Clause]
[LIMIT N][ OFFSET M]
4,UPDATE 查詢
UPDATE table_name SET field1=new-value1, field2=new-value2
[WHERE Clause]
5,DELETE 語句
DELETE FROM table_name [WHERE Clause]
5,LIKE 子句
SELECT field1, field2,...fieldN
FROM table_name
WHERE field1 LIKE condition1 [AND [OR]] filed2 = 'somevalue'
Example
mysql> use RUNOOB;
Database changed
mysql> SELECT * from runoob_tbl WHERE runoob_author LIKE '%COM';
+-----------+---------------+---------------+-----------------+
| runoob_id | runoob_title | runoob_author | submission_date |
+-----------+---------------+---------------+-----------------+
| 3 | 學習 Java | RUNOOB.COM | 2015-05-01 |
| 4 | 學習 Python | RUNOOB.COM | 2016-03-06 |
+-----------+---------------+---------------+-----------------+
2 rows in set (0.01 sec)
最后附一篇MySQL添加用戶、刪除用戶與授權(quán)的博客,鏈接。
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。