JavaScript Editor Js editor     Website development 



Main Page

Previous Page
Next Page

Using Mysqladmin

The mysqladmin utility, as the name might imply, is used to perform administrative-level tasks on your databases. This includes:

  • Stopping MySQL (as you saw in the previous sections)

  • Setting the root user's password

  • Creating databases

  • Deleting database

  • And more!

A number of the things you can do with mysqladmin can also be accomplished more directly within the mysql client, which you'll see later in the chapter and in the book. But, in the meantime, another use of mysqladminconfirming the operation of the server by checking its statuswill be demonstrated here. This is a great way to test that MySQL is running, to check that you have the right root userpassword, if necessary, and to confirm the version of MySQL being used.

To demonstrate how most things you do with MySQL, aside from installing, starting, and stopping it, will be essentially the same from one operating system to the next, I'll take images from three different operating systems for these steps. Throughout the rest of the book, you'll also see different operating systems in use, but the functionality and most of the exact commands will be the same regardless of the platform.

To use mysqladmin:

1.
Make sure that MySQL is running!

The MySQL server (mysqld) must be running in order for you to use mysqladmin. If MySQL is not currently running, start it now using the steps outlined earlier.

2.
Log in to your system from a command-line interface and move into the MySQL installation directory (Figure 2.25).

Figure 2.25. Start by accessing the MySQL installation directory from within a command-line interface.


Again, refer back to the steps outlined earlier in the chapter for your particular operating system. You'll need to use a DOS console window or the Terminal application, and then use the cd command to change directories.

3.
Find out the current version and status of MySQL (Figure 2.26).

Figure 2.26. The mysqladmin utility can display useful information about your MySQL server.


At the prompt, type one of the following and press Enter or Return:

bin\mysqladminu root -p version status (Windows)

or

./bin/mysqladminu root -p version status(Mac OS X and Unix)

If you haven't already established a root user's password, omit the -p argument. If you have established that password, use the command as shown and enter that password at the prompt.

If everything worked, you should see how long the MySQL server has been running (in seconds) as well as other statistics.

4.
See what other mysqladmin options are possible (Figure 2.27).

Figure 2.27. A partial list of the commands that the mysqladmin utility accepts.


At the prompt, type one of the following and press Enter or Return:

bin\mysqladminu root -p --help (Windows)

or

./bin/mysqladminu root -p --help (Mac OS X and Unix)

Again, you'll likely need to change this slightly depending upon whether or not a root userpassword has already been established.

Tips

  • Depending upon many combinations of things, you may not have to use -u root when invoking mysqladmin. I think it's best to be explicit, though.

  • To check if MySQL is running without viewing all the status details, try just

    mysqladmin -u root -p ping


Previous Page
Next Page


JavaScript Editor Js editor     Website development


©