Home > Database > Mysql Tutorial > body text

How to create and delete databases in MySQL

不言
Release: 2019-03-09 11:00:07
Original
3763 people have browsed it

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;
Copy after login

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

mysql> CREATE DATABASEexampledbDEFAULT CHARACTER SETutf8;
Copy after login

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
Copy after login

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;
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template