<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>TechniTip.Net &#187; PHP/MySQL</title>
	<atom:link href="http://technitip.net/tag/php_mysql/feed" rel="self" type="application/rss+xml" />
	<link>http://technitip.net</link>
	<description>TechniTip.Net - Useful tips regarding technical stuff for things like Linux, MySQL, Apache, PHP, Linux Server, iPhone and more.</description>
	<lastBuildDate>Fri, 03 Feb 2012 18:31:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<image>
<link>http://technitip.net</link>
<url>http://technitip.net/wp-content/plugins/maxblogpress-favicon/icons/favicon-66.ico</url>
<title>TechniTip.Net</title>
</image>
		<item>
		<title>MySQL Optimize Script</title>
		<link>http://technitip.net/mysql-optimize-script</link>
		<comments>http://technitip.net/mysql-optimize-script#comments</comments>
		<pubDate>Wed, 31 Dec 2008 00:08:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP/MySQL]]></category>
		<category><![CDATA[optimize]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://planlos.org/~harry/php/?p=114</guid>
		<description><![CDATA[A nice small PHP script which simple connects to a given MySQL server and optimizes all databases and included tables. Only the internal table &#8220;information_schema&#8221; is skipped because it will show an error. Working with MySQL version 5.0.32 and PHP version 5.2.0 on Debian Etch. Script is designed to run from command line &#8220;php optimize.php&#8221; [...]<div style="clear: both;">
<strong>Related posts:</strong><ol>
<li><a href='http://technitip.net/simple-mysql-backup-script' rel='bookmark' title='Simple MySql Backup Script'>Simple MySql Backup Script</a></li>
<li><a href='http://technitip.net/mysql-performance-tips' rel='bookmark' title='MySQL Performance Tips'>MySQL Performance Tips</a></li>
<li><a href='http://technitip.net/simple-php-flood-protection-class' rel='bookmark' title='Simple PHP Flood Protection Class'>Simple PHP Flood Protection Class</a></li>
</ol></div>]]></description>
			<content:encoded><![CDATA[<p>A nice small PHP script which simple connects to a given MySQL server and optimizes all databases and included tables. Only the internal table &#8220;information_schema&#8221; is skipped because it will show an error.</p>
<p>Working with MySQL version 5.0.32 and PHP version 5.2.0 on Debian Etch.</p>
<p>Script is designed to run from command line &#8220;php optimize.php&#8221; maybe from a cron job. Be careful: avoid running this script during your server &#8220;rush hour&#8221;, it may slow down your server.</p>
<pre>&lt;?php
/***********************************************************
 optimimze.php - optimizes all databases and tables of the
                 given mysql host.

 2008 - technitip.net
 ***********************************************************/

$mysqlhost = "localhost"; // enter MySQL host
$mysqluser = "user";      // enter MySQL user
$mysqlpwd  = "password";  // enter password

###########################################

$connection = mysql_connect($mysqlhost, $mysqluser, $mysqlpwd);
if (mysql_error())
{
  echo "Could not connect to database server! " . mysql_error() . "\n";
  exit;
}

$db_list = mysql_list_dbs();
$i = 0;
$cnt = mysql_num_rows($db_list);

while ($i &lt; $cnt)
{
  $db = mysql_db_name($db_list, $i);
  ###########################################
  mysql_select_db($db, $connection);
  $result = mysql_list_tables($db);

  while ($row = mysql_fetch_row($result))
  {
    if ( $db == "information_schema" )
      continue;

    echo $db . " : `" . $row[0] . "`";

    $sql = "OPTIMIZE TABLE `".$row[0]."`";
    $erg = mysql_query($sql, $connection) or die(mysql_error());
    $data= mysql_fetch_array($erg, MYSQL_ASSOC);

    if($data)
    {
      echo " - " . $data['Msg_text'] . "\n";
    }
  }
  ###########################################
  $i++;
}

?&gt;</pre>
<div id="facebook_like"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Ftechnitip.net%2Fmysql-optimize-script&amp;layout=standard&amp;show_faces=true&amp;width=500&amp;action=like&amp;font=segoe+ui&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:500px; height:80px;" allowTransparency="true"></iframe></div><div style="clear: both;"><p><strong>Related posts:</strong><ol>
<li><a href='http://technitip.net/simple-mysql-backup-script' rel='bookmark' title='Simple MySql Backup Script'>Simple MySql Backup Script</a></li>
<li><a href='http://technitip.net/mysql-performance-tips' rel='bookmark' title='MySQL Performance Tips'>MySQL Performance Tips</a></li>
<li><a href='http://technitip.net/simple-php-flood-protection-class' rel='bookmark' title='Simple PHP Flood Protection Class'>Simple PHP Flood Protection Class</a></li>
</ol></p></div>]]></content:encoded>
			<wfw:commentRss>http://technitip.net/mysql-optimize-script/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple MySql Backup Script</title>
		<link>http://technitip.net/simple-mysql-backup-script</link>
		<comments>http://technitip.net/simple-mysql-backup-script#comments</comments>
		<pubDate>Tue, 30 Dec 2008 13:44:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP/MySQL]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://planlos.org/~harry/php/?p=92</guid>
		<description><![CDATA[The following example scripts performs a simple backup of all MySQL databases. The resulting .sql file is automatically zipped. Using &#8220;find&#8221; backups older than 3 days are deleted, so you will get complete backups of the last 3 days. This script is intended to be called periodically (e.g. every day) from cron: 2 2       * [...]<div style="clear: both;">
<strong>Related posts:</strong><ol>
<li><a href='http://technitip.net/vmware-esx-backup-script' rel='bookmark' title='VMWare ESX Backup Script'>VMWare ESX Backup Script</a></li>
<li><a href='http://technitip.net/mysql-optimize-script' rel='bookmark' title='MySQL Optimize Script'>MySQL Optimize Script</a></li>
<li><a href='http://technitip.net/running-rsync-and-sudo-over-ssh' rel='bookmark' title='Running Rsync and Sudo over SSH'>Running Rsync and Sudo over SSH</a></li>
</ol></div>]]></description>
			<content:encoded><![CDATA[<p>The following example scripts performs a simple backup of all MySQL databases. The resulting .sql file is automatically zipped. Using &#8220;find&#8221; backups older than 3 days are deleted, so you will get complete backups of the last 3 days.</p>
<p>This script is intended to be called periodically (e.g. every day) from cron:</p>
<pre>2 2       * * *   root /root/scripts/mysql_backup.sh</pre>
<pre>#/bin/sh
now=`date "+%Y-%m-%d"`
user="mysql_user"
password="mysql_password"
path="/home/backup/"

cd $path

mysqldump -u $user -p$password  --all-databases | gzip -c &gt; backup_all_$now.sql.gz

# delete files older than 3 days
find . -name "*.gz" -type f -mtime +3 -exec rm {} ";"</pre>
<div id="facebook_like"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Ftechnitip.net%2Fsimple-mysql-backup-script&amp;layout=standard&amp;show_faces=true&amp;width=500&amp;action=like&amp;font=segoe+ui&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:500px; height:80px;" allowTransparency="true"></iframe></div><div style="clear: both;"><p><strong>Related posts:</strong><ol>
<li><a href='http://technitip.net/vmware-esx-backup-script' rel='bookmark' title='VMWare ESX Backup Script'>VMWare ESX Backup Script</a></li>
<li><a href='http://technitip.net/mysql-optimize-script' rel='bookmark' title='MySQL Optimize Script'>MySQL Optimize Script</a></li>
<li><a href='http://technitip.net/running-rsync-and-sudo-over-ssh' rel='bookmark' title='Running Rsync and Sudo over SSH'>Running Rsync and Sudo over SSH</a></li>
</ol></p></div>]]></content:encoded>
			<wfw:commentRss>http://technitip.net/simple-mysql-backup-script/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

