Find Database Size on MySQL

Determine MySQL Database Size

Determining the size of MySQL database

Determining the size of specific MySQL database can be done in so many way, you can do it from the Linux file system perspective or from MySQL.

The most accurate way to find MySQL database size recommended by Percona is by checking the information_schema and this can be done by running the following query (Replace db_name with the database name you want to investigate) :

Database size in GB:

SELECT table_schema "Database Name", SUM( data_length + index_length)/1024/1024/1024 "Database Size (GB)" FROM information_schema.TABLES where table_schema = 'db_name';

Database size in MB:

SELECT table_schema "Database Name", SUM( data_length + index_length)/1024/1024 "Database Size (MB)" FROM information_schema.TABLES where table_schema = 'db_name';


Connect to MSSQL on Linux ?! Can i ?


How to connect or test MSSQL connection from Linux Command Line ?

There are several ways to do so but for me i am using the following:

First install FreeTDS and UnixODBC:

yum search unixODBC
yum install unixODBC
yum install freetds

Then you can use "tsql" , below is an example and you can use also -h for help:

tsql -H  ServerIP_HERE  -U userName  -P passWord  -p 1433

FreeTDS(May 14, 2011)                                    

       tsql - utility to test FreeTDS connections and queries

       tsql   { -S servername [-I interface] | -H hostname -p port }
              -U username [-P password] [-o options]

       tsql   -C

       tsql  is  a diagnostic tool provided as part of FreeTDS. It uses the TDS protocol directly to con-
       nect to Sybase or Microsoft SQL Servers, and allows the user to issue queries that test the  capa-
       bilities of FreeTDS.

       tsql  is  *not* a replacement for a complete isql, such as sqsh (  It is designed to
       rely on the lowest level FreeTDS library, tdslib, as a way to isolate potential bugs in the proto-
       col implementation.

Below is a very simple php script which can test a MSSQL Connection from Linux server to external server to see if it's successful or not:

[code]<?php // Change ip.ip.ip.ip below with the destination server ip $server = 'ip.ip.ip.ip'; // Connect to MSSQL , change user with username and pass with the password $link = mssql_connect($server, 'user', 'pass'); if (!$link) { die('Something went wrong while connecting to MSSQL'); } else { echo "connected successfully\n"; } ?>[/code]