When you need to take a backup of a large MySql database, then “mysqldump” command come most handy and does the task in few seconds. But for that we need to access the web server or database through SSH. And database access in 99% cases is not allowed from remote location for security reasons.
I found myself in such situation recently and PhpMyAdmin export feature was not working due to script timeout or memory issues. So I googled for this and after 15-20 minutes of searching I found this very useful and working small script for the job.
$User = ""; // Put New user -- CPanel user or MySQL user with All permissions is fine.
$Password = ""; // Put New Password
$DatabaseName = ""; // Put Database name
$File = ""; // Put the complete path here -- /home/user/database.sql for example
$Results = shell_exec( "mysqldump --allow-keywords --opt -u$User -p$Password $DatabaseName > $File");
Just upload the file on the web server and execute it. Do remember to specify the path of the file so that it is accessible from the web e.g. provide any path which is inside public_html or www folder on most servers.
It will take just few seconds for 300-400MB database and then you can download the file and use it as you like.
When using special characters in UTF-8 character encoding, sometimes when you read something from mysql database then it is not displayed properly on the web page. Many of you like me may try to change the character encoding of the HTML page to ISO-8859-1, that may work sometimes but this is not the proper solution to the problem.
Irrespective of the character encoding used by MySql to store the text data, when you query something using SQL it returns the data encoded in the latin charset. This is defined in the mysql config files, as described below:
The character_set_results system variable indicates the character set in which the server returns query results to the client. This includes result data such as column values, and result metadata such as column names.
To change the character encoding to UTF8 or other, you need to use “mysql_set_charset()” mysql function in PHP. Pass the correct encoding name required and now future mysql queries will return result using new encoding.
When I recently started working on some of my ideas of a web application, then CakePHP is the framework of my choice. I am working with it since last 3-4 years and have a good understanding of the features and architecture. Now, I planned to use as much AJAX as possible in this application, I need to find a good Javascript framework/library. JQuery is the best available JS framework at present, with everyone trying to use this in any possible way. JQuery is lightweight, fast, supports multiple browsers and quick to code.
But as of now CakePHP’s built-in AJAX features does not use JQuery, they are based on “prototype”. In the new version CakePHP, which is under development, they are planning to provide support for multiple JS libraries. But that is very less documented and not available for production ready sites.
So, I must put off using AJAX and Javascript helpers and have to custom code various JS functionality. Earlier I thought that it would take lot of time and I might need to manipulate few core files to integrate the JQuery and CakePHP. But when I started using JQuery and learned more about it – I found that they already have great features and plug-ins which would make them independent of the server side language or framework.
To submit a form using AJAX in CakePHP, I just needed to write 3 lines of JS code and include two plug-ins of JQuery – “livequery” and “form”. That is it!
I would have written more code, If i have used that default AJAX Helper which uses prototype. I have just started with JQuery and I am very impressed with it like most of you. I do not know when CakePHP will have support for it, but I am going to use it from today for all AJAX and Javascript requirements in CakePHP.
Search the site
Random Testimonial
- ~ Elance ID – gtownwebdev
"Nirvaat was responsive, fast, knowledgeable, professional and the price was great. I am thrilled to have found" - Read more testimonials »
What's the little bird saying?
- @pavanagrawal If computers will start asking questions then who will answer it!!!!! we have to creat a human version of google! in reply to pavanagrawal 1 week ago
- Turn a USB Flash Drive Into Extra Virtual RAM [USB Drive] http://bit.ly/cb9fOT 2010-06-28
- Is Entrepreneurship Just About the Exit? http://bit.ly/99oan9 2010-06-12
- More updates...
Posting tweet...

July 25, 2010 in