Leilin Peng Share: MySQL database deleted

  Use ordinary user login MySQL server, you may need special permissions to create or delete MySQL database, so here we logged in as root, root user has the highest authority.

  In the process of deleting the database, it is important to be very careful, because after the delete command, all data will be lost.

  drop command to delete the database

  drop command format:

  drop database <database name>;

  Such as deleting the database named CODERCTO:

  mysql> drop database CODERCTO;

  Delete the database using mysqladmin

  You can also delete command in the terminal to use mysql mysqladmin command.

  The following examples delete database CODERCTO (the database has been created in the previous section):

  [root@host]# mysqladmin -u root -p drop CODERCTO

  Enter password:******

  After these steps to delete the database command, there will be a prompt box to confirm it really delete the database:

  Dropping the database is potentially a very bad thing to do.

  Any data stored in the database will be destroyed.

  Do you really want to drop the 'CODERCTO' database [y/N] y

  Database "CODERCTO" dropped

  Use PHP script to remove the database

  Mysqli_query use PHP functions to create or delete MySQL database.

  This function takes two arguments and returns TRUE if executed successfully, otherwise it returns FALSE.

  grammar

  mysqli_query(connection,query,resultmode);

  Parameter Description

  connection required. MySQL provisions connection to use.

  query the necessary provisions query string.

  resultmode optional. A constant. It can be any of the following values:

  MYSQLI_USE_RESULT (If you need to retrieve large amounts of data, use this)

  MYSQLI_STORE_RESULT (default)

  Examples

  The following example illustrates the use of PHP mysqli_query function to delete the database:

  Delete Database

   '; $ Sql ​​=' DROP DATABASE CODERCTO '; $ retval = mysqli_query ($ conn, $ sql); if ($ retval!) {Die (' Delete database failed:. 'Mysqli_error ($ conn));} echo "Database CODERCTO deleted successfully \ n "; mysqli_close ($ conn);?>

  Note: When using PHP script to delete the database, does not appear to confirm whether to delete a message, just delete the specified database, so when you delete a database to be especially careful. (Editor: Leilin Peng Source: network intrusion deleted)

Guess you like

Origin www.cnblogs.com/pengpeng1208/p/10971495.html