admin-tools

Backup all MySQL databases automagicly with the PHP admin script

Server administration software like Cpanel, Plesl, Webmin etc have already their backup solutions. But they are runned mostly once a week or max a day because of performance reasons. Let say we just want to backup all of our mysql-databases every 2 hours.

To do this:

  • Create a directory like /backup/mysql
  • Save code below under something like backup_mysql.php
  • Chmod it to 755
  • Run it manually or with cronjobs /root/scripts/backup_mysql.php
#!/usr/bin/php
<?php
// use this if your php.ini does not allow shell etc #!/usr/bin/php -n

Repair all mysql databases-tables with PHP

phpMyAdmin is a great tool but there is no option to repair all databases at once yet. Imagine you have no shell-access and need to repair all your 100 databases. It would take long time. This small PHP-Script lets you list, analyze and repair all your databases belong to same user at once.

If you already have shell access you can do it with mysqlcheck:

mysqlcheck -u root -p --auto-repair --check --optimize --all-databases


Repair with PHP:

  

Page generation time and http-referers with PHP

Webmasters want to know where all visitors coming from, which pages they visit and how long does it take webpages to load in miliseconds. This tutorial shows how to save your visitors/website details like referrer, browser/client, ip-address, langind-page in three steps. Remember if your scripts ends with exit() or die() command, footer code will not work. Just remove that commands or put them below footer code.

  1. Create your mysql table
  2. Add top-code
  3. Add bottom-code

SQL Query

Import big SQL Files under WAMP or LAMP ?

I want to import a sql file, which is larger than 100 MB. I cant upload it with Phpmyadmin, because PHP's upload limit is 8 MB. I tried with Mysql Console ie: "mydatabasename < c:\path\to\file.sql" but got en standart mysql query-error. How to do it easily?

Syndicate content

CafeWebmaster.com(CW) is a free online community for webdevelopers and beginners. Anybody can share their code, articles, tips, tutorials, code-examples or other webdesign related material on the site. Newbies can submit their questions and reply to existing questions. CW does not guarantee or warrant reliability of code, data and information published on the site. Use the site on your own risk. The site takes no responsibility of direct or indirect loss or any kind of harm to its users. The site also doesn't take responsibility of infected files or source code with any kind of infection or viruses, worms, spywares, malwares, trojan horses. CW reserves the right to edit, move, or delete any of content for any reason.