mysqladmin
is a command-line utility in Linux used to perform administrative tasks on MySQL servers. It is a part of the MySQL server installation package and provides a variety of options to manage MySQL databases.
Overview
The mysqladmin
command is used to perform administrative tasks on the MySQL server. It can be used to perform tasks such as creating and dropping databases, checking the status of the server, restarting the server, and more. The following are some examples of how to use the mysqladmin
command:
- To check the status of the MySQL server:
mysqladmin status
- To create a new database:
mysqladmin create new_database
- To drop a database:
mysqladmin drop old_database
- To restart the MySQL server:
mysqladmin shutdown
mysqladmin -u root -p shutdown
The first command will shut down the server without prompting for a password. The second command will prompt for the root user’s password before shutting down the server.
Options
The following table lists the available options for the mysqladmin
command:
Option | Description |
---|---|
-c | Check tables for corruption |
-f | Force operations |
-h | Hostname |
-p | Password |
-P | Port number |
-r | Flush logs and remove old binary logs |
-u | Username |
-v | Verbose mode |
-w | Wait for the server to restart after shutting down |
Troubleshooting tips
- If you encounter an error message that says “Access denied for user ‘root’@’localhost’ (using password: NO)”, try using the
-p
option with your password. - If you encounter an error message that says “Can’t connect to MySQL server on ‘localhost’ (10061)”, make sure that the MySQL server is running and that you have specified the correct hostname and port number.
- If you encounter an error message that says “Got error: 1045: Access denied for user ‘root’@’localhost’ (using password: YES)” when trying to connect to the server, make sure that you have specified the correct username and password.
Notes
- The
mysqladmin
command should be run as the root user or a user with administrative privileges. - Some options, such as
-p
and-u
, require an argument to be passed immediately after the option. For example,-pPASSWORD
or-uroot
.