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>
相关文章
相关标签/搜索