Skip to main content

MySQL Commands to real time monitoring and usage


$ mysqldump db_name my_table
$ mysqldump db_name my_table > output.sql
$ mysqldump --no-data db_name my_table > dump_table_name.sql
$ mysqldump --add-drop-table db_name my_table > dump_table_name.sql
$ mysqladmin create db_name
$ mysqladmin drop db_name
$ mysqladmin flush-privileges
$ mysqladmin ping
$ mysqladmin reload
$ mysqladmin kill ps_id,ps_id...
$ mysqladmin --user=root shutdown
$ mysqladmin variables
$ mysqlimport db_name file_name ...
$ safe_mysqld
$ myisamchk table_name.MYI

mysql> GRANT ALL ON db_name TO user_name@localhost IDENTIFIED BY 'password'
mysql> GRANT ALL ON db_name TO user_name@'%' IDENTIFIED BY 'password'

$ mysql --help | less
$ mysqld --help
$ mysqlshow --help | less
$ mysqldump --help | less
$ mysqlshow    - show all databases.
$ mysqlshow db_name - all tables in particular database.
$ mysqlshow db_name BA* - all tables which start from BA letters.

mysql> \?
mysql> use db_name;
mysql> show databases;
mysql> show databases like 'ba%'
mysql> show tables;
mysql> describe table_name;
mysql> select user(), now(), version(), database();
+---------------+---------------------+----------------+------------+
| user()        | now()               | version()      | database() |
+---------------+---------------------+----------------+------------+
| ana@localhost | 2003-01-05 21:24:27 | 4.0.1-alpha-nt | test       |
+---------------+---------------------+----------------+------------+

mysql> show tables from db_name
mysql> show tables from db_name like '__ab%'
mysql> show columns from table_name
mysql> show columns from table_name from db_name
mysql> show grants for user_name
mysql> show index from table_name
mysql> show index from table_name from db_name
mysql> show processlist
mysql> show status
mysql> show table status from db_name
mysql> show variables

Comments

Popular posts from this blog

About MySQL - Database history Support and Versioning

About MySQL: MySQL was created by a Swedish company. David Axmark (left) and Michael "Monty" Widenius,  MySQL AB, founded by David Axmark, Allan Larsson and Michael "Monty" Widenius. Original development of MySQL by Widenius and Axmark began in 1994. The first version of MySQL appeared on 23 May 1995. It was initially created for personal usage from mSQL based on the low-level language ISAM, which the creators considered too slow and inflexible. They created a new SQL interface, while keeping the same API as mSQL. By keeping the API consistent with the mSQL system, many developers were able to use MySQL instead of the (proprietarily licensed) mSQL antecedent. Support: The MySQL server software itself and the client libraries use dual-licensing distribution. They are offered under GPL version 2, or a proprietary license. MySQL AB owns the copyright to the MySQL source code. This means that MySQL AB can distribute MySQL under several different l...

MySQL thread error code of 1032- Translate binlog completely to avoid error

Could not execute Update_rows event on table db.table; Can't find record in 'table', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's   master log mysql-bin.262297, end_log_pos 1983208 As of my knowledge the causing stop of slave SQL thread error code of 1032, due to lack of sync between Master - Slave. In our case, slave got an Update event form master, but that particular record was not available in the slave. (Of course, that was deleted on Master n Slave separately) You would get this error only if the binlog_format is set to ROW_BASED or MIXED mode. So, now check that particular binlog at that position where replication stopped with this error. When you convert the binlog with mysqlbinlog command, you may see some junk characters   where you were expecting some DMLs which caused the error(In our case its an Update statement). So you can use below command to translate binlog completely: mysqlbinlog --base64-output=DECO...

MySQL Architecture -Client Server Architecture

Client/Server Overview The MySQL database system operates using a client/server architecture. The server is a central program that manages database contents, and client programs connect to the server to retrieve or modify the data. MySQL also includes non-client utility programs and scripts. MySQL Server:   This is the mysqld program that manages database and tables. Most users choose binary MySQL distribution that includes a server ready to run with the capabilities they need, but it's also possible to compile MySQL from source. Client Programs:  These are programs that communicate with the server by sending requests to it over a network connection. The server acts on each request and returns a response to the client. For example you can use the mysql client to send queries to the server, and the server returns the query results. A client program can connect locally to a server running on the same machine or remotely to a server running on a different mac...