The MySQL is a relational database management system that is used by many developers and organizations to manage large amounts of data. In this article, we will discuss how to create a database in MySQL from the command line on a Linux system.
How to Create a MySQL Database from the Command Line
Step 1: Before creating a MySQL database, you need to ensure that MySQL is installed on your Linux system, you can do this by running the following command:
Step 2: Once MySQL is installed, you can log in to the MySQL server using the following command:
Step 3: Now, to create a new database, you can use the following command:
Step 4: By default, the newly created database can only be accessed by the root user and If you want to allow other users to access the database, you need to grant them permissions so to view the databases, execute:
Step 5: Next to begin working with new database use:
If you are done with doing changes to the database then to exit it use the following command:
How to Remove MySQL Database through Command Line
Now in case you need to delete a MySQL database then just use the below given syntax:
Conclusion
Creating a MySQL database from the command line on a Linux system is an easy process that can be completed in a few steps. By performing the given procedure, you can easily create a new database, grant permissions, and exit MySQL. This is a useful skill for developers and system administrators who need to manage large amounts of data using MySQL.