3、MySQL常用操作

  • 1、MySQL连接
C:\Users\Administrator.EIT-20171107TIY>mysql -u root -p
Enter password: ******
  • 2、断开连接
mysql> exit;
Bye
  • 3、创建数据库,有两种方式
    • 1、create datebase 数据库名
C:\Users\Administrator.EIT-20171107TIY>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.15 MySQL Community Server - GPL

Copyright (c) 2000, 2019, 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> create database database_test;
Query OK, 1 row affected (0.01 sec)

mysql>
  • 2、使用 mysqladmin 创建数据库
C:\Users\Administrator.EIT-20171107TIY>mysqladmin -u root -p create database_tes
t1
Enter password: ******
  • 4、删除数据库,有两种方式
    • 1、drop database 数据库名
mysql> drop database database_test;
Query OK, 0 rows affected (0.01 sec)
  • 2、使用 mysqladmin 删除数据库
C:\Users\Administrator.EIT-20171107TIY>mysqladmin -u root -p drop data_test;
Enter password: ******
Dropping the database is potentially a very bad thing to do.
Any data stored in the database will be destroyed.

Do you really want to drop the 'data_test;' database [y/N] y
Database "data_test;" dropped
  • 5、选择数据库 ,use 数据库名
mysql> use runoob;
Database changed
mysql>
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • MYSQL 基础知识 1 MySQL数据库概要 2 简单MySQL环境 3 数据的存储和获取 4 MySQL基本操...
    Kingtester阅读 12,393评论 5 116
  • 什么是数据库? 数据库是存储数据的集合的单独的应用程序。每个数据库具有一个或多个不同的API,用于创建,访问,管理...
    chen_000阅读 9,472评论 0 19
  • 1.导出整个数据库 mysqldump -u 用户名 -p –default-character-set=lati...
    往你头上敲三下阅读 3,751评论 1 10
  • 1.linux下启动mysql的命令:mysqladmin start/ect/init.d/mysql star...
    ljwheyxy阅读 3,060评论 0 2
  • ORA-00001: 违反唯一约束条件 (.) 错误说明:当在唯一索引所对应的列上键入重复值时,会触发此异常。 O...
    我想起个好名字阅读 10,962评论 0 9

友情链接更多精彩内容