Difference between revisions of "DB/Mysql"
< DB
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
This is reference regarding mysql databases. It's worth to mention that MySQL open source project now is called MariaDB. These commands below are mainly tested with Amazon RDS instances. | This is reference regarding mysql databases. It's worth to mention that MySQL open source project now is called MariaDB. These commands below are mainly tested with Amazon RDS instances. | ||
= Connect = | |||
<source lang=bash> | |||
mysql -h database-eu.example.com -u admin@database-eu -p | |||
mysql -h database-eu.example.com -u admin@database-eu -pPassw0rd123 | |||
</source> | |||
;References | |||
*[[Local_port_forwarding_-_straight_tunnel]] | |||
= Check MySQL current connections = | = Check MySQL current connections = | ||
<source> | <source> |
Revision as of 20:21, 22 January 2019
This is reference regarding mysql databases. It's worth to mention that MySQL open source project now is called MariaDB. These commands below are mainly tested with Amazon RDS instances.
Connect
mysql -h database-eu.example.com -u admin@database-eu -p mysql -h database-eu.example.com -u admin@database-eu -pPassw0rd123
- References
Check MySQL current connections
watch -n1 "mysql -u root -pPASSWORD -te \"select id, command, host, time, left(info,60) from information_schema.processlist where info is not null or time > 300 order by time asc;\" 2>/dev/null"
Mysql client - prompt
How to show the name of the current database in the MySQL prompt If you need the name of the currently selected database in your MySQL prompt, use the following lines in your MySQL my.cnf
configuration file entry like this [mysql] prompt='mysql(\d)> '
Now, when you connect, the MySQL prompt will look like what’s shown below:
mysql((none))> use test; #Database changed mysql(test)> mysql(test)> use mysql; #Database changed mysql(mysql)>
Queries
Check size of all tables
SELECT table_schema as `Database`, table_name AS `Table`, round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB` FROM information_schema.TABLES ORDER BY (data_length + index_length) DESC;