Example of a MySQL database built on the command line

Source: Internet
Author: User
Tags character set create database mysql database


To create a database of different character sets and delete a database under the command line:

[Root@lamp ~]#/usr/local/mysql/bin/mysql-uroot-p ' admin123 '
Warning:using a password on the command line interface can is 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), 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命令, the Byrd_default default encoding is UTF8, because the default encoding that I set when I compile MySQL is 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, encoding is a GBK database.
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 |
+--------------------+
Rows in Set (0.00 sec)

mysql> drop Database GBK1; #删除名字为gbk1的数据库
Query OK, 0 rows affected (0.19 sec)

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的数据库存在则删除, prompt warning if not present
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>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.