今天开始通过自学MySQL总结一些方法和一些基础的内容,写在这里,和大家一起讨论学习进步。(现在东西少,第一次写有这类结构的东西,过几天会出一个整体目录结构,方便查看)

安装部署直接跳过,我使用的版本是5.7,直接开写

1启动和关闭服务指令

1.1windows下(mysql57为mysql服务名称):

启动:net start mysql57

关闭:net stop mysql57

1.2linux下(mysql 为mysql服务名称):

启动:[root@localhost ~]service mysql start

关闭:[root@localhost ~]service mysql stop

1.3windows下cmd窗体进入mysql:

cd到mysql安装的bin目录下:

 C:Windowssystem32>cd C:Program FilesMySQLMySQL Server 5.7bin 

连接mysql服务器:

C:Program FilesMySQLMySQL Server 5.7bin>mysql -uroot -p
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 3
Server version: 5.7.17-log MySQL Community Server (GPL)

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>
mysql 代表客户端命令,-u 后面跟连接的数据库用户,-p 表示需要输入密码。

1.4数据库管理

1.4.1创建一个orderManage数据库

mysql> create database orderManage;
Query OK, 1 row affected (0.00 sec)

1.4.2展示所有的数据库

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cluster |
| mysql |
| test |
| orderManage|
+--------------------+ 5 rows in set (0.00 sec)
可以发现,在上面的列表中除了刚刚创建的orderManage外,还有另外 4 个数据库,它们都是安装
MySQL 时系统自动创建的,其各自功能如下。
1、 information_schema:主要存储了系统中的一些数据库对象信息。比如用户表信息、列信息、权限信息、字符集信息、分区信息等。
2、 cluster:存储了系统的集群信息。
3 、mysql:存储了系统的用户权限信息。
4、 test:系统自动创建的测试数据库,任何用户都可以使用。

1.4.3选择进入某一个数据

选择进入orderManage数据库中:

mysql> use ordermanage;
Database changed

由此可以发现,选择进入数据库时候,数据库的名称是不区分大小写的

1.4.4查看此数据库中的所有表

mysql> show tables;
Empty set (0.00 sec)

此时,显示orderManage数据库中是没有表的(Empty set表示操作结果为空)

 1.4.5删除数据库

mysql> drop database ordermanage;
Query OK, 0 rows affected (0.01 sec)

 

内容来源于网络如有侵权请私信删除

文章来源: 博客园

原文链接: https://www.cnblogs.com/19930521zhang/p/14754193.html

你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!