Free Source Code and Tutorials

Custom Search

Drop Database using MySqladmin:

You can create any database using MySQL mysqladmin binary. It’s very important to understand that If you drop a database, that means to delete any database then all the data in it will be deleted forever.So always think twice before dropping a database.

Here is an example to delete a database created in the previous chapter:

[root@host]# mysqladmin -u root -p drop  Database tutorials

Enter password:******


First of all, this will provide a warning and it will confirm if you really want to delete this database or “no”.

Any data stored in the database will be destroyed.


Do you really want to drop the ‘ Database tutorials‘ database [y/N] y

Database ” Database tutorials” dropped

Drop Database using PHP Script:

PHP uses the mysql_query function in order  to either  create or delete a MySQL database.


bool mysql_query( sql, connection );


Command Detail
sql Required – SQL query either to create or delete a MySQL database
connection Optional – if not specified, then last opened connection will be used by  mysql_connect.


An example to delete a database:


  1. <html>
  2. <head>
  3. <title>Deleting MySQL  Tutorial Database</title>
  4. </head>
  5. <body>
  6. <?php
  7. $dbhost = 'localhost';
  8. $dbusername = 'root';
  9. $dbpassword = 'rootpassword';
  10. $conn = mysql_connect($dbhost, $dbusername, $dbpassword);
  11. if(! $con )
  12. {
  13.   die('Could not connect: ' . mysql_error());
  14. }
  15. echo 'Connected successfully<br />';
  17. $result = mysql_query( $sql, $con );
  18. if(! $result )
  19. {
  20.   die('Could not delete database: ' . mysql_error());
  21. }
  22. echo "Database TUTORIALS deleted successfully\n";
  23. ?>
  24. </body>
  25. </html>
Facebook Comments
(Visited 9 times, 1 visits today)
Share this

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked * © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!

%d bloggers like this: