MySQL Administration Commands

MySQL has an administration program called mysqladmin, which is used to do things such as adding a database, dropping (deleting) a database (and all of its tables), or reloading the grant tables (access control tables).

Unlike mysql, mysqladmin does not have an interactive interface. You pass mysqladmin the options on the command line, and it does the work requested; then you are back at your shell prompt.

To add a database, do something like this:

mysqladmin –uadmin –p create NewDatabaseName 

The system asks you for a password, just as the mysql program does if you have not supplied one on the command-line. If you enter the correct password, you will be returned to the shell prompt and the database will be created, but there is no notification that a database has been created. An error, however, will result in some sort of error message.

If you get into the mysql> command-line interface and enter show databases, you will see the new database listed along with the others.

Also, you can drop databases. To drop a database means to delete it and all of its contents. To drop a database, just substitute drop in place of create. Since drop can blow away an entire database and all of its data, a prompt asking you if you really want to drop the database is displayed with a default of N (No) so that you can’t accidentally hit Enter and lose your data.

Other administrative tasks can be done with the mysqladmin program. The MySQL documentation describes everything in great detail. If you need to do more than adding or deleting (dropping) databases, refer to the latest MySQL documentation.

Perl Database Programming
Perl Database Programming
ISBN: 0764549561
EAN: 2147483647
Year: 2001
Pages: 175

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: