Home  >  Article  >  Database  >  How to create and delete databases in MySQL

How to create and delete databases in MySQL

不言
不言Original
2019-03-09 11:00:073747browse

MySQL is the most popular database for web development. After installing mysql on the system, we start with database creation. In this article, we will explain how to create and delete databases in MySQL server.

How to create and delete databases in MySQL

1. Create a database from the mysql prompt:

To create a database from the mysql command prompt, you first need to use administrative privileges Log in to the mysql server.

# mysql -u root -p
mysql> CREATE DATABASEexampledb;

You can also set the default character set to utf8 through the following definition command.

mysql> CREATE DATABASEexampledbDEFAULT CHARACTER SETutf8;

2. Create a database from the system command prompt:

Using the mysqladmin command we can create a database from the linux shell or windows command line. This is useful for running queries for automated tasks from a shell or bash script.

# mysqladmin -u root -p createexampledb

3. Delete the database from the MySQL prompt:

To delete the database from the mysql command prompt, first log in to the mysql server with administrative rights.

# mysql -u root -p
mysql> DROP DATABASEexampledb;

4. Delete the database from the system command prompt:

We can also delete any database from the Linux shell or Windows command line using the mysqladmin command. This is useful for running queries from shell scripts.

# mysqladmin -u root -p drop exampledb

This article has ended here. For more exciting content, you can pay attention to other related column tutorials on the php Chinese website! ! !

The above is the detailed content of How to create and delete databases in MySQL. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn