This is a non-reversible action and should be executed with caution. 3)Delete a MySQL databaseĭeleting a MySQL database is as simple as running a single command. These databases are necessary for the proper functionality of the MySQL installation. The information_schema, mysql, performance_schema, and sys databases are created at installation time and they are storing information about all other databases, system configuration, users, permission and other important data. The output will look something like this: +-+ You can list all databases that exist on our MySQL or MariaDB server with the following command: SHOW DATABASES In the output above, Query OK means that the query was successful, and 1 warning tells us that the database already exists and no new database was created. Query OK, 1 row affected, 1 warning (0.00 sec) To avoid errors if the database with the same name as you are trying to create exists you can use the following command: CREATE DATABASE IF NOT EXISTS database_name If you try to create a database that already exists you will see the following error message: ERROR 1007 (HY000): Can't create database 'database_name' database exists To create a new MySQL database run the following command, just replace database_name with the name of the database that you want to create: CREATE DATABASE database_name To open the MySQL prompt, type the following command and enter the MySQL root user password when prompted: mysql -u root -p All commands will be executed as a root user. How to Manage MySQL Databases and Users from the Command Line Before you beginīefore you start with this tutorial, we are assuming that you already have MySQL or MariaDB server installed on your system.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |