Wiki

Applications

Firefox

Add-ons

My preferred add-ons:

Feeds, News & Blogging

Web Development

Download Management

Privacy & Security

Search Tools

Interface Customizations

Bookmarks

Language Tools

Photos, Music & Videos

Social & Communication

Alerts & Updates

Other

MySQL

Database Management

Check Tables Indexes

check table %TABLE% for upgrade;

Create User and Database

mysql> create database DATABASENAME;
mysql> grant all privileges on DATABASENAME.* to 'USERNAME'@'LOCALHOST' identified by 'PASSWORD';
mysql> flush privileges;
mysql> exit

Get Table List

show tables;

Get Database List

show databases;

Select Database

use %DATABASENAME%

SQL Profiler

Activate or deactivate the profiler for the current session:

set profiling=1;
set profiling=0;

Display queries ID and durations:

show profiles;

Display query informations:

show profile for query %QUERYID%;

Display query information details:

show profile %VALUE% for query %QUERYID%;

where %VALUE% can be: ALL, CPU, BLOCK IO, CONTEXT SWITCHES, IPC, PAGE FAULTS, SOURCE or SWAPS.

Command-line Client

Normal login:

mysql -D %DATABASENAME% -u %USERNAME% -p

Execute script:

mysql -D %DATABASENAME% -u %USERNAME% -p < %SCRIPTFILE% > %OUTPUTFILE%

Get Current State

show status like '%PARAMS%%';

Transaction Log Management

Purge log files (with MySQL replication):

mysql -u root -p -e "PURGE BINARY LOGS BEFORE '2011-5-13 10:06:06';"

SQL statement:

FLUSH LOGS

Unix command line:

mysqladmin flush-logs

Replications

Check Status

show slave status \G;

Start

slave start;

Postgress

Backup

Crontab user postgres:

00 23 * * * /%PATHTOSCRIPT%/backuppostgres.sh >>/dev/null

Script:

DATE=$(date +%Y-%m-%d)
pg_dump DBNAME | gzip > /data/backup/DBNAME_${DATE}.gz

Command Line Client

su postgres
psql -d %DATABASENAME%

Get All Tables Names

SELECT tablename FROM pg_tables

Get All Databases

psql -l

VMWare

Remove Snapshots

vmware-cmd /vmfs/volumes/%VMFSSTORAGE%/%VMNAME%/%VMNAME%.vmx removesnapshots

Rename VMDK File

/usr/sbin/vmkfstools -E %OLDNAME%.vmdk %NEWNAME%.vmdk

ToDo

http://www.commentcamarche.net/faq/9773-reinitialiser-le-mot-de-passe-root-de-mysql

mysqladmin status

Calculate Total Database Index Size

mysql -u mysqlusername -p -e “SELECT CONCAT(ROUND(SUM(index_length)/(1024*1024), 2), ' MB') AS 'Total Index Size' FROM information_schema.TABLES WHERE table_schema LIKE '%DATABASE%';”

Calculate the Total Size of Table Data

mysql -u mysqlusername -p -e “SELECT CONCAT(ROUND(SUM(data_length)/(1024*1024), 2), ' MB') AS 'Total Data Size' FROM information_schema.TABLES WHERE table_schema LIKE 'databasename';”

wiki/applications.txt · Last modified: 2011/10/20 13:44 by ach
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki