命令行建立Mysql数据库的例子
发布:smiling 来源: PHP粉丝网 添加日期:2015-04-17 17:11:47 浏览: 评论:0
建立数据库我们可以很多的方式来创建了,小编来为各位介绍使用命令行建立Mysql数据库的例子,希望例子对各位有帮助,命令行下建立不同字符集的数据库、删除数据库:
- [root@lamp ~]# /usr/local/mysql/bin/mysql -uroot -p'admin123'
- Warning: Using a password on the command line interface can be insecure.
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 2
- Server version: 5.6.16 Source distribution
- Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
- mysql> create database byrd_default; #建议一个叫做byrd_default的数据库
- Query OK, 1 row affected (0.08 sec)
- mysql> show databases like 'byrd%'; #查看以byrd开头的数据库,
- +------------------+
- | Database (byrd%) |
- +------------------+
- | byrd_default |
- +------------------+
- 1 row in set (0.00 sec)
- mysql> show create database byrd_default; #查看系统建立byrd_default命令,byrd_default默认编码是utf8,因为我编译mysql的时候设置的默认编码为utf8
- +--------------+-----------------------------------------------------------------------+
- | Database | Create Database |
- +--------------+-----------------------------------------------------------------------+
- | byrd_default | CREATE DATABASE `byrd_default` /*!40100 DEFAULT CHARACTER SET utf8 */ |
- +--------------+-----------------------------------------------------------------------+
- 1 row in set (0.00 sec)
- mysql> create database gbk default character set gbk collate gbk_chinese_ci; #建立一个名字叫做gbk,编码方式是gbk的数据库
- Query OK, 1 row affected (0.00 sec)
- mysql> show create database gbk;
- +----------+-------------------------------------------------------------+
- | Database | Create Database |
- +----------+-------------------------------------------------------------+
- | gbk | CREATE DATABASE `gbk` /*!40100 DEFAULT CHARACTER SET gbk */ |
- +----------+-------------------------------------------------------------+
- 1 row in set (0.00 sec)
- mysql> show databases; #所有数据库表
- +--------------------+
- | Database |
- +--------------------+
- | information_schema |
- | byrd_default |
- | gbk |
- | gbk1 |
- | gbk2 |
- | gbk3 |
- | gbk4 |
- | mysql |
- | performance_schema |
- | test |
- | ultrax |
- +--------------------+
- 11 rows in set (0.00 sec)
- mysql> drop database gbk1; #删除名字为gbk1的数据库
- Query OK, 0 rows affected (0.19 sec) --phpfensi.com
- mysql> drop database gbk2;
- Query OK, 0 rows affected (0.00 sec)
- mysql> drop database gbk3;
- Query OK, 0 rows affected (0.00 sec)
- mysql> drop database gbk4;
- Query OK, 0 rows affected (0.01 sec)
- mysql> show databases;
- +--------------------+
- | Database |
- +--------------------+
- | information_schema |
- | byrd_default |
- | gbk |
- | mysql |
- | performance_schema |
- | test |
- | ultrax |
- +--------------------+
- 7 rows in set (0.00 sec)
- mysql> drop database if exists byrd_default; #如果byrd_default的数据库存在则删除,如果不存在则提示警告
- Query OK, 0 rows affected (0.00 sec)
- mysql> show databases;
- +--------------------+
- | Database |
- +--------------------+
- | information_schema |
- | gbk |
- | mysql |
- | performance_schema |
- | test |
- | ultrax |
- +--------------------+
- 6 rows in set (0.00 sec)
- mysql>
Tags: Mysql命令行 建立Mysql
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)