91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

mysql 庫基礎命令匯總

發布時間:2020-08-15 07:07:15 來源:網絡 閱讀:311 作者:小辛linux 欄目:數據庫

1 登錄mysql數據庫

[root@db02--52 ~]# mysql -uroot -p

Enter password: 

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 9

Server version: 5.6.34-log Source distribution


Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql> 

2 查看當前登錄的用戶:

mysql> select user();

+----------------+

| user()         |

+----------------+

| root@localhost |

+----------------+

1 row in set (0.20 sec)


mysql> 

3 創建數據庫haha,并查看已建庫完整語句

mysql> create database haha; 創建數據庫haha

Query OK, 1 row affected (0.00 sec)


mysql> show create database haha;查看剛健的數據庫

+----------+---------------------------------------------------------------+

| Database | Create Database                                               |

+----------+---------------------------------------------------------------+

| haha     | CREATE DATABASE `haha` /*!40100 DEFAULT CHARACTER SET utf8 */ |

+----------+---------------------------------------------------------------+

1 row in set (0.00 sec)

mysql> show databases; 查看所有的數據庫

+--------------------+

| Database           |

+--------------------+

| information_schema |

| haha               |

| mysql              |

| oldboy             |

| oldgril            |

| performance_schema |

| xinpan             |

| xu                 |

+--------------------+

8 rows in set (0.00 sec)


mysql> 

4 創建用戶hehe  使之可以管理數據庫haha

mysql> create user hehe@'localhost' identified by 'oldboy123'

    -> ;創建本地用戶hehe 授權數據庫密碼

Query OK, 0 rows affected (0.06 sec)


mysql> grant all on haha.* to hehe@'localhost';haha為數據庫,hehe為用戶

Query OK, 0 rows affected (0.00 sec)

5 查看創建的用戶hehe擁有哪些權限

mysql> show grants for hehe@'localhost';查看創建的用戶hehe擁有哪些權限

+-------------------------------------------------------------------------------------------------------------+

| Grants for hehe@localhost                                                                                   |

+-------------------------------------------------------------------------------------------------------------+

| GRANT USAGE ON *.* TO 'hehe'@'localhost' IDENTIFIED BY PASSWORD '*FE28814B4A8B3309DAC6ED7D3237ADED6DA1E515' |

| GRANT ALL PRIVILEGES ON `oldboy`.* TO 'hehe'@'localhost'                                                    |

| GRANT ALL PRIVILEGES ON `hehe`.* TO 'hehe'@'localhost'                                                      |

| GRANT ALL PRIVILEGES ON `haha`.* TO 'hehe'@'localhost'                                                      |

+-------------------------------------------------------------------------------------------------------------+

4 rows in set (0.03 sec)

6 查看當前數據庫里有哪些用戶。

mysql> 

mysql> select user,host from mysql.user;

+-----------+------------+

| user      | host       |

+-----------+------------+

| keke      | %          |

| oldboy    | %          |

| xinjia    | %          |

| mha       | 10.0.0.%   |

| rep       | 10.0.0.%   |

| root      | 127.0.0.1  |

| bbs       | 172.16.1.% |

| wordpress | 172.16.1.% |

| root      | db02--52   |

| haha      | localhost  |

| hehe      | localhost  |

| oldboy    | localhost  |

| root      | localhost  |

| system    | localhost  |

+-----------+------------+

14 rows in set (0.00 sec)


mysql> 

6 進入oldboy數據庫

mysql> use oldboy

Database changed

mysql> 

7 查看當前所在的數據庫

mysql> select database();

+------------+

| database() |

+------------+

| oldboy     |

+------------+

1 row in set (0.00 sec)


mysql> 

8 創建一張表xiaoke 字段id和name varchar(16)


mysql> create table xiaoke ( id int(4) not null, name varchar (16) not null);

Query OK, 0 rows affected (0.63 sec)


mysql> 

9查看建表結構以及表結構的sql語句

mysql> desc xiaoke 查看表的結構

    -> ;

+-------+-------------+------+-----+---------+-------+

| Field | Type        | Null | Key | Default | Extra |

+-------+-------------+------+-----+---------+-------+

| id    | int(4)      | NO   |     | NULL    |       |

| name  | varchar(16) | NO   |     | NULL    |       |

+-------+-------------+------+-----+---------+-------+

2 rows in set (0.03 sec)

查看表結構的sql語句

mysql> show full columns from xiaoke; 查看表結構的sql語句

+-------+-------------+-----------------+------+-----+---------+-------+---------------------------------+---------+

| Field | Type        | Collation       | Null | Key | Default | Extra | Privileges                      | Comment |

+-------+-------------+-----------------+------+-----+---------+-------+---------------------------------+---------+

| id    | int(4)      | NULL            | NO   |     | NULL    |       | select,insert,update,references |         |

| name  | varchar(16) | utf8_general_ci | NO   |     | NULL    |       | select,insert,update,references |         |

+-------+-------------+-----------------+------+-----+---------+-------+---------------------------------+---------+

2 rows in set (0.00 sec)


mysql> 

10 插入一條數據“1,aini”

mysql> insert into test(id,name) values(1,'aini');

Query OK, 1 row affected (0.02 sec)

mysql> select * from test;

+----+------+--------+

| id | age  | name   |

+----+------+--------+

|  1 | NULL | oldboy |

|  1 | NULL | oldboy |

|  1 | NULL | aini   |

+----+------+--------+

3 rows in set (0.02 sec)


mysql> 

11 再批量插入2行數據“2,xiaoxu”“3,xiaoxin”

mysql> insert into test(id,name) values(2,'xaioke'),(3,'xiaoxin');

Query OK, 2 rows affected (0.00 sec)

Records: 2  Duplicates: 0  Warnings: 0


mysql> select * from test;

+----+------+---------+

| id | age  | name    |

+----+------+---------+

|  1 | NULL | oldboy  |

|  1 | NULL | oldboy  |

|  1 | NULL | aini    |

|  2 | NULL | xaioke  |

|  3 | NULL | xiaoxin |

+----+------+---------+

5 rows in set (0.00 sec)


12 查詢名字為oldboy的記錄

mysql> select * from test where name='oldboy';

+----+------+--------+

| id | age  | name   |

+----+------+--------+

|  1 | NULL | oldboy |

|  1 | NULL | oldboy |

+----+------+--------+

2 rows in set (0.00 sec)


mysql> 

13 把數據庫id等于1的名字oldboy更改為oldgril

mysql> select * from test where name='oldboy';

+----+------+--------+

| id | age  | name   |

+----+------+--------+

|  1 | NULL | oldboy |

|  1 | NULL | oldboy |

+----+------+--------+

2 rows in set (0.00 sec)


mysql> updata test set name='oldgirl' where id='1';


mysql> select * from test;

+----+------+---------+

| id | age  | name    |

+----+------+---------+

|  1 | NULL | oldgirl |

|  1 | NULL | oldgirl |

|  1 | NULL | oldgirl |

|  2 | NULL | xaioke  |

|  3 | NULL | xiaoxin |

+----+------+---------+

5 rows in set (0.00 sec)


mysql> 

未完待續。。。。。





向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

汤阴县| 万年县| 乌兰浩特市| 绍兴县| 兴义市| 南召县| 衢州市| 洛川县| 通山县| 康乐县| 宿迁市| 广安市| 东宁县| 云安县| 绥德县| 通州区| 航空| 霞浦县| 科尔| 繁峙县| 江阴市| 肇东市| 齐齐哈尔市| 桂东县| 丰顺县| 广州市| 杭锦旗| 芷江| 平乐县| 瓦房店市| 南漳县| 崇仁县| 木里| 上杭县| 池州市| 敦化市| 余干县| 若羌县| 含山县| 清远市| 大渡口区|