FORUM HOME | WHUK BLOG   
WEB HOSTING UK AFFORDABLE WEBSITE HOSTING SERVICES IN UNITED KINGDOM
PHP LINUX SHARED HOSTING WINDOWS ASP.NET HOSTING PACKAGES
ECOMMERCE HOSTING ASP MSSQL MS ACCESS ODBC FRONTPAGE HOSTING
CPANEL WHM FANTASTICO RESELLER DEDICATED SERVER WEB HOSTING
CHEAP PLESK CPANEL HTML MYSQL BEST UK VPS HOSTING COMPANY
CHEAP RELIABLE UK HOSTING PROVIDER SINCE 2001
MANAGED WEB HOSTING SERVICE
AFFORDABLE WEBSITE HOSTING SERVICES IN UNITED KINGDOM

Web Hosting UK Forums | Linux Windows Dedicated Server and cPanel VPS Hosting Forum » Technical Support » Semi-Dedicated Servers

Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)  
Old 16-04-11, 09:54 AM
Junior Member
 
Join Date: Apr 2011
Posts: 16
Default MySQL databases optimization on Plesk server

This article goes over mass optimization of MySQL databases and tables. This can be done in a per database basis or to all databases.

Optimize MySQL Databases in Plesk :

1. Open an SSH connection to the server and log in as the root user.
2. Once logged in as the root user, create a file name optimize.sh with the following data:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#!/bin/sh
DBNAME=$2
if [ -e /etc/psa/.psa.shadow ]; then
PLESKJAWNS="-uadmin -p`cat /etc/psa/.psa.shadow`"
else
PLESKJAWNS=""
fi

printUsage() {
echo "Usage: $0"
echo " --optimize <dbname>"
echo " --optimizeall"
echo " --repair <dbname>"
echo " --repairall"
return
}
doAllTables() {
# get the table names
TABLENAMES=`mysql $PLESKJAWNS -D $DBNAME -e "SHOW TABLES\G;"|grep 'Tables_in_'|sed -n 's/.*Tables_in_.*: \([_0-9A-Za-z]*\).*/\1/p'`
# loop through the tables and optimize them
for TABLENAME in $TABLENAMES
do
mysql $PLESKJAWNS -D $DBNAME -e "$DBCMD TABLE $TABLENAME;"
done
}
doAllDatabases() {
# get the database names
DATABASES=`mysql $PLESKJAWNS -e "Show Databases" | grep -v + | grep -v psa`
for DATABASE in $DATABASES
do
# get the table names
TABLENAMES=`mysql $PLESKJAWNS -D $DATABASE -e "SHOW TABLES\G;"|grep 'Tables_in_'|sed -n 's/.*Tables_in_.*: \([_0-9A-Za-z]*\).*/\1/p'`
# loop through the tables and optimize them
for TABLENAME in $TABLENAMES
do
mysql $PLESKJAWNS -D $DATABASE -e "$DBCMD TABLE $TABLENAME;"
done
done
}
if [ $# -eq 0 ] ; then
printUsage
exit 1
fi
case $1 in
--optimize) DBCMD=OPTIMIZE; doAllTables;;
--optimizeall) DBCMD=OPTIMIZE; doAllDatabases;;
--repair) DBCMD=REPAIR; doAllTables;;
--repairall) DBCMD=REPAIR; doAllDatabases;;
--help) printUsage; exit 1;;
*) printUsage; exit 1;;
esac
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# Update the permissions on the file using the following command:
[root@server~]# chmod +x optimize.sh

To repair and optimize a single database, run the following commands:

[root@server~]# ./optimize.sh --repair DBNAME
[root@server~]# ./optimize.sh --optimize DBNAME

#To repair and optimize a all databases, run the following commands:

[root@server~]# ./optimize.sh --repairall
[root@server~]# ./optimize.sh --optimizeall


Done.... Browse your website and and EnjoY the Speed...

Last edited by Alec:D; 16-04-11 at 10:16 AM.
Reply With Quote

  #2 (permalink)  
Old 25-04-11, 10:04 AM
Junior Member
 
Join Date: Jan 2011
Posts: 20
Default

Hi,

A very informative information you have provided to all of us. But i have a question that this could be only done if a client has root access, will you please share for the person don't have a root access but need to optimization MySQL databases. In other words if i have a shared web hosting plan then how can i do the same to optimize MySQL database.
Reply With Quote

  #3 (permalink)  
Old 26-04-11, 04:35 PM
Junior Member
 
Join Date: Apr 2011
Posts: 16
Default Mysql Database Optimization from Cpanel/PHPMyadmin

Yes, you can repair/optimize database from Cpanel as well as PHPMyadmin

just you do not optimize all database at once, it can be done individually

Cpanel >> Mysql databases >> under modify databases tag, you will see 2 buttons :

1) Check DB
2) Repair DB

By clicking on Repair DB, it will repair and optimize your database, it will repair all tables of databases,

If you want to repair and optimize any particular table, then you need to do it through PHPMyadmin :

Cpanel >> phpMyAdmin >>

log in to your phpMyAdmin and select the database whose tables you wish to optimize/repair.

Select the tables that need repair/optimize and pick the Optimize/Repair table action from the drop-down menu located below the tables' list.

If you tick on check all , action will be applied for all.

The tables will be repaired/Optimized and you will get a confirmation screen.

Done..

Reply With Quote

  #4 (permalink)  
Old 27-04-11, 09:28 AM
Moderator
 
Join Date: Nov 2010
Posts: 131
Default

@ AlecD :

Cool information, keep it up

Regards
Moderator
__________________
UK VPS Hosting || SEO Server || Cloud Hosting
Looking for extra income ?
Join our webhosting affiliate program and earn upto £300 Webhosting UK Affiliate
Reply With Quote

  #5 (permalink)  
Old 30-04-11, 08:05 AM
new member
 
Join Date: Apr 2011
Posts: 4
Default

I use MySQL databases. Nice information. I like it
Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT. The time now is 06:16 AM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Copyright 2001-2010 Web Hosting UK. All rights reserved.
Web Hosting UK Forum





Site Map

Shared Cloud
Shared Cloud From £1

Affiliate Program
Earn up to £300 Per Sale

Dedicated Servers
Dedicated Server Hosting

Cloud Hosting
Cloud Server Hosting

Load Balanced Server
Load Balancing Server

VPS Hosting
Linux VPS Hosting

Windows VPS
Windows 2003 VPS

Zimbra Hosting
Zimbra Email Hosting

cPanel Hosting
Shared Linux Hosting

Windows Hosting
Shared Windows Hosting

Coldfusion Hosting
Windows Coldfusion Hosting

cPanel Reseller Hosting
Reseller Hosting

Windows Reseller
Windows Reseller Hosting

Email Web Hosting
Email Hosting

Semi-Dedicated Server
Semi-Dedicated Hosting

Remote Backup Plans
Offsite Backup Service


cpanel hosting
Knowledgebase Articles

Pre-Sales Question
Web Hosting FAQ's

Dedicated Hosting
Dedicated Server FAQ's

Virtual Private Servers
VPS Hosting

PHP MySQL Hosting
cPanel Hosting

Windows Hosting
ASP MSSQL Hosting

Domain Name
Domain registration FAQ's

CMS Hosting
CMS Hosting FAQ's

Payment Gateways
Payment FAQ's


Support Tutorials

cPanel Tutorials
cPanel Flash Tutorials

Wordpress Tutorials
Wordpress Flash Tutorials

Plesk Tutorials
Plesk Flash Tutorials

PhpMyadmin Tutorials
PhpMyadmin Flash Tutorials

Drupal Tutorials
Drupal Flash Tutorials

Mambo Tutorials
Mambo Flash Tutorials

Joomla Tutorials
Joomla Flash Tutorials

More Hosting Tutorials