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.
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!