MYSQL學習筆記(二)數據庫基本操做

數據庫(Database)是按照數據結構來組織、存儲和管理數據的倉庫;

1、數據庫鏈接mysql

    1.鏈接本地數據庫web

mysql -u 用戶名 -p

    2.鏈接遠程數據庫sql

mysql -h 數據庫ip地址 -u 用戶名 -p

2、顯示全部數據庫數據庫

show databases;

3、建立數據庫數據結構

create database 數據庫名;

4、選擇數據庫spa

use 數據庫名;

5、刪除數據庫code

drop database 數據庫名;

6、 CMD中執行演示orm

#鏈接本地數據庫
C:\Users\iboilder>mysql -u root -p
#輸入密碼
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 5.5.47 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| library |
| mysql |
| myweb |
| performance_schema |
| query |
| test |
+--------------------+
7 rows in set (0.01 sec)

#建立數據庫
mysql> create database t1;
Query OK, 1 row affected (0.30 sec)

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| library |
| mysql |
| myweb |
| performance_schema |
| query |
| t1 |
| test |
+--------------------+
8 rows in set (0.00 sec)

#選擇數據庫
mysql> use t1;
Database changed
mysql>
相關文章
相關標籤/搜索