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>

你可能感兴趣的:(3、MySQL常用操作)