Well, sometimes, you probably need to optimise your MySQL tables. In order to avoid the hassle loggin to your remote SSH server, you probably want to write a script and put it somewhere accessible under HTTP protocol, e.g., http://www.yourdomain.com/somewheresafe/optimise.php
The php well supports mysql connections. It is very handy to have the following script ready.
<?php
require("conn.php");
if (!$dbok) { die ('db not ok');}
$alletabellen = mysql_query("SHOW TABLES");
while($tabel = mysql_fetch_assoc($alletabellen))
{
foreach ($tabel as $db => $tabelnaam)
{
mysql_query("OPTIMIZE TABLE `".$tabelnaam."`", $link) or die(mysql_error());
echo "$tabelnaam optimized.\n";
}
}
?>
Inside conn.php, you will need to set up the connections to $link.
Doing this regularly will ensure a good performance of your website, especially if you have quite many database tables.
DevOps / Site Reliability Engineering
- How to Clean Up NVM Node Versions Except One?
- Monitoring 28 VPS Machines including a Raspberry Pi with Nezha Dashboard
- Python/Bash Script to Print the Optimized Parameters for MySQL Servers
- Learn to Manage Your MySQL Database with a Python Script
- A Simple PHP Command Line Tool to Convert MySQL Tables from MyISAM to InnoDB in Specified Database
- How to Print MySQL Table Summary using PHP?
- Secure the Linux Server by Disallow the Remote Root Login (SSH and FTP and MySQL database)
- Bash Script to Check, Repair, Optimise and Backup MySQL database
- Duplicate a MySQL table - Copy Table / Duplicate Database / PHP Script
- MySQL server stopped due of out of memory exception on Ubuntu VPS
- Running Apache Server (PHP + MySQL) on Raspberry PI
- How to Optimise SQL Queries? Quick Tips
- Recovery Models in SQL Server
- Database Optimisation Script in PHP
–EOF (The Ultimate Computing & Technology Blog) —
208 wordsLast Post: Codeforces: A. Super Agent
Next Post: Codeforces: B. Taxi