Support
- Advanced Backup
- Client Side
- Cloud Enterprise
- ColdFusion
- Control Panel
- cPanel
- Customer Portal
- DNS Information
- Dedicated Servers
- DirectAdmin
- Domain Name
- dotDefender
- Dreamweaver
- FileCatalyst
- Front Page
- FTP
- General Information
- Hosted Exchange & SharePoint
- IIS6
- IIS7
- Juniper Netscreen Firewalls
- Linux
- List Server
- MIVA Merchant
- MySQL
- Adddatabase
- Amconversion
- Aspstring
- Coldfusionstring
- Connectionstrings
- Phpmyadmin
- Upgradedatabase
- Mysql
- Backup my MySQL database via SSH
- Change the collation on a MySQL database via PhpMyAdmin
- Repair a corrupt or invalid MySQL table
- Import and Export MySQL dump file from phpMyAdmin
- Manage your MySQL Database with Navicat
- Use Sequel Pro for Mac OS X to manage MySQL databases
- Optimize MySQL Databases in Plesk
- Access
- Controlpanel
- Perl
- Advisable MMM Solutions
- Managing Your MMM Environment
- Php
- Common Issues With MMM
- How To Add A Timeout Variable
- Patching / Server Updates
- phpMyAdmin
- Plesk
- Policies and Procedures
- Premium Spam Filtering
- Programming
- Ruby on Rails
- Search Engine Submission
- SharePoint 3
- SharePoint 2010
- SiteDesigner
- SmarterMail 3
- SmarterMail 4
- SmarterMail 5
- SmarterMail 6
- SmarterMail 7
- SmarterStats
- SmarterTrack
- SQL Server
- Secure Socket Layer (SSL)
- Uploading Your Website
- Video Tutorials
- Windows Server 2003
- Windows Server 2008
- Web Design
- WordPress
- Advanced Monitoring
- MediaWiki
- Enkompass
- Microsoft Outlook 2010
- Android
- Outlook Web Access
- Critical Availability Service
- NAS Data Transfer
- Customer Portal Demos
- Joomla
- Moodle
- Cloud Dedicated
- Gallery CMS
- phpBB
- Standard Monitoring
- Righteous Restore
- NAS (Network Attached Storage)
- Networking
- SmarterMail 8
- PCI Security Scan
- LinkTiger
- Windows Cloud VPS
- Linux Cloud VPS
- Linux VPS
- Windows VPS
- Hyper V
- ENSIM
- Alert Logic
- Webmin
- e107
- Vbulletin
- VPN
- Visual Vault
- Mozilla Thunderbird
- PyroCMS
- Active Directory
- Vmware Related
- Drupal
Optimize MySQL Databases in Plesk
This article goes over mass optimziation of MySQL databases and tables. This can be done in a per database basis or to all databases.
- Open an SSH connection to the server and log in as the root user.
- Once logged in as the root user, create a file name optimize.sh with the following data:
- Update the permissions on the file using the following command:
- To repair and optimize a single database, run the following commands:
- To repair and optimize a all databases, run the following commands:
#!/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
chmod +x optimize.sh
./optimize.sh --repair DBNAME./optimize.sh --optimize DBNAME
./optimize.sh --repairall./optimize.sh --optimizeall