MySQL数据库基本操作
2013-08-30 23:49
323 查看
1,命令行登录命令
mysql -h localhost -u root -p
2,创建数据库
查看帮助:\h create database 或者 help create database
[option1, option2,...]代表可选的 {option1 | option2}代表要选择其中的某一项
SCHEMA是DATABASE的同义词
IF NOT EXISITS:如果不存在同名数据库才会执行创建语句;如果不添加此选项,而且存在同名数据库的话,则会报错
创建参数:
[DEFAULT] CHARACTER SET [=] charset_name:设定默认字符集
[DEFAULT] COLLATE [=] collation_name:设定默认校对集
参考在SQL语句中使用COLLATE
创建数据库示例:
查看已创建的数据库的定义
查看已创建哪些数据库
3,删除数据库
mysql -h localhost -u root -p
C:\Users\lenovo>mysql -u root -p Enter password: ***** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.5.28 MySQL Community Server (GPL) Copyright (c) 2000, 2012, 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.
2,创建数据库
查看帮助:\h create database 或者 help create database
mysql> \h create database Name: 'CREATE DATABASE' Description: Syntax: CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name [create_specification] ... create_specification: [DEFAULT] CHARACTER SET [=] charset_name | [DEFAULT] COLLATE [=] collation_name CREATE DATABASE creates a database with the given name. To use this statement, you need the CREATE privilege for the database. CREATE SCHEMA is a synonym for CREATE DATABASE.
[option1, option2,...]代表可选的 {option1 | option2}代表要选择其中的某一项
SCHEMA是DATABASE的同义词
IF NOT EXISITS:如果不存在同名数据库才会执行创建语句;如果不添加此选项,而且存在同名数据库的话,则会报错
创建参数:
[DEFAULT] CHARACTER SET [=] charset_name:设定默认字符集
[DEFAULT] COLLATE [=] collation_name:设定默认校对集
参考在SQL语句中使用COLLATE
创建数据库示例:
mysql> create database if not exists test_db -> default character set = utf8;
查看已创建的数据库的定义
mysql> show create database test_db;
查看已创建哪些数据库
mysql> show databases;
3,删除数据库
mysql> drop database test_db;
相关文章推荐
- MySQL数据库Windows下命令行基本操作
- mySql数据库的基本操作
- MySQL数据库的基本操作
- MySQL数据库——修改约束基本操作
- mysql数据库基本操作
- MySQL数据库——插入记录的基本操作
- mysql数据库的基本操作
- MySQL数据库学习02-数据表的基本操作:创建
- Linux下MySQL数据库常用基本操作 一
- MySQL数据库的基本操作命令
- mysql数据库常用的基本SQL语句--数据库数据操作
- 使用Dos操作MySQL数据库的基本用法
- mysql数据库基本操作 (数据类型)
- iOS连接mysql数据库及基本操作
- MySQL数据库基本操作
- MySQL数据库的基本操作
- MYSQL数据库基本操作语句
- Linux下MySQL数据库常用基本操作
- MySQL数据库最基本的操作
- MySQL数据库的基本操作命令