Tuesday, November 26, 2013

Mysqladmin Commands in Linux

mysqladmin is a command-line utility the comes with MySQL server and it is used by Database Administrators to perform some basic MySQL tasks easily such as setting root password, changing root password, monitoring mysql processes, reloading privileges, checking server status etc.

1.To set MySQL Root password:
# mysqladmin -u root password YOURNEWPASSWORD
 
2.to Change MySQL Root password?
#mysqladmin -u root -p123456 password 'xyz123'
 
3.To check MySQL Server is running?
# mysqladmin -u root -p ping
 
4.To Check which MySQL version I am running?
# mysqladmin -u root -p version
 
5.To Find out current Status of MySQL server?
#mysqladmin -u root -ptmppassword status 

6.To check status of all MySQL Server Variable’s and value’s?
# mysqladmin -u root -p extended-status
 
7.To see all MySQL server Variables and Values?
# mysqladmin  -u root -p variables
 
8.To check all the running Process of MySQL server?
#mysqladmin -u root -p processlist
 
9.To create a Database in MySQL server?
# mysqladmin -u root -p create databasename
 
10.To drop a Database in MySQL server?
# mysqladmin -u root -p drop databasename
 
11.To reload/refresh MySQL Privileges?
# mysqladmin -u root -p reload;
# mysqladmin -u root -p refresh;
 
The reload command tells the server to reload the grant tables. The refresh command
 flushes all tables and reopens the log files.
 
12.To shutdown MySQL server Safely?
#mysqladmin -u root -p shutdown 

other commands:
# /etc/init.d/mysqld stop
# /etc/init.d/mysqld start
 
13.Some useful MySQL Flush commands
 
# mysqladmin -u root -p flush-hosts
# mysqladmin -u root -p flush-tables
# mysqladmin -u root -p flush-threads
# mysqladmin -u root -p flush-logs
# mysqladmin -u root -p flush-privileges
# mysqladmin -u root -p flush-status
 
 
14.To kill Sleeping MySQL Client Process?
to see: # mysqladmin -u root -p processlist
 
Run the following id with process id: 
# mysqladmin -u root -p kill 5 

15.To run multiple mysqladmin commands together?
#mysqladmin  -u root -p processlist status version 

16.To Connect remote mysql server:
# mysqladmin  -h 172.16.25.126 -u root -p
 
 
17.To execute command on remote MySQL server:
# mysqladmin  -h 172.16.25.126 -u root -p status
 
 
18.To start/stop MySQL replication on a slave server?
# mysqladmin  -u root -p start-slave
# mysqladmin  -u root -p stop-slave
 
19.To store MySQL server Debug Information to logs?
# mysqladmin  -u root -p debug
 
20.To view mysqladmin options and usage:
# mysqladmin --help 
 
 
 
Source 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

No comments: