MySQL Useful Command

If you are the database administrator, today post will help you to mange your server easily.

mysqladmin ping
-check whether the server is alive

mysqladmin status
-display a short server status message.

mysqladmin variable
-display the server system variables and their value.

mysqladmin proc stat
-all command shortened

mysqladmin processlist
-Shows active mysql connections and queries

mysqladmin drop database_name
-Dropsdeletes the selected database

mysqladmin create database_name
-Creates a mysql database

mysql -u username -p password databasename < databasefile.sql
-Restores a MySQL database from databasefile.sql

mysqldump -u username -p password databasename > databasefile.sql
-Backup MySQL database to databasefile.sql

Identify slow MySQL query

Sometimes, MySQL will make your server pain if you have user abusing it. Mick Genie will teach you to identify which MySQL database creating the problem to your server.

Actually MySQL can log all of the those query that taking longer time than certain seconds.

1. Login to the server as root.
2. Open your my.cnf with your editor.

vi /etc/my.cnf

3. In the [mysqld] section, add the line as below.

log-slow-queries = /var/log/mysql-slow.log
long_query_time = 3

this meant that the log will logged to /var/log/mysql-slow.log and the query time is 3 seconds.

4. Save the my.cnf by typing “:wq!” and press enter.
Continue reading Identify slow MySQL query

Reboot Server within a network in Windows Platform

Do you ever try to reboot or shut down a server/PC within a network?

The mystery from Microsoft have done if you are running with administrator role, just try to the command as below if you could like to reboot/shutdown.

1. Open command prompt by Press Windows+R and type in cmd.
2. Type in “shutdown /m \\computername /r” if you could like to reboot.

The General format was as below:

shutdown \\computername /l /a /r /t:xxmsg” /y /c

  • \\computername: Use this switch to specify the remote computer to shut down. If you omit this parameter, the local computer name is used.
  • /l (Note that this is a lowercase “L” character): Use this switch to shut down the local computer
  • /a: Use this switch to quit a shutdown operation. You can do this only during the time-out period. If you use this switch, all other parameters are ignored.
  • /r: Use this switch to restart the computer instead of fully shutting it down.
  • /t:xx: Use this switch to specify the time (in seconds) after which the computer is shut down. The default is 20 seconds.
  • msg: Use this switch to specify a message during the shutdown process. The maximum number of characters that the message can contain is 127.
  • /y: Use this switch to force a “yes” answer to all queries from the computer.
  • /c: Use this switch quit all running programs. If you use this switch, Windows forces all programs that are running to quit. The option to save any data that may have changed is ignored. This can result in data loss in any programs for which data is not previously saved.

Within the above description you may force all of the query and etc from the command to reboot/shutdown a server/PC.

Have fun.

Article from: http://support.microsoft.com/kb/317371