Development
Dump MySQL database with a row limit for tables
by z7oofy on Sep.15, 2010, under MySQL
Hey Guys, Have you ever wondered how to get a copy of your production database, may be to setup your local development environment to look like your production ? biggest problem that you will face is deploying your database to reflect your production database, because sometimes it might want to downloading Gigabytes to download a copy of your production database. The solution is for this is simple get a minimized copy or a version of the database where it gives you all the tables with a limited number of rows in each of them. sounds good ?
Okay then here is the trick..
We all know in MySQL there is an command line tool mysqldump where we can provide a few parameters into it and get a copy of any database. what we have to do is give it a little more parameters, then it will limit the number of rows copied from each table into your dump. so here is the command..
mysqldump -u {Username} -p –opt –where=”true LIMIT 500″ {databasename} > {dumpfilename.sql}
once you press enter, it will ask you for the database password in the next line, provide the password.. you are done
Please note that mysqldump is located in the /bin folder of your mysql installation.
Can’t connect to MySQL server on (10060)
by z7oofy on Nov.18, 2009, under Development, Interesting, Music, MySQL
If you are trying connect to a remote MySQL server and if your MySQL client giving you the error message
Can’t connect to MySQL server on ‘< Host name or IP address >‘ (10060)
Check whether your Public IP is allowed to access server,whether your IP is in the Allowed host list.
Restore MySQL Database Backup using command line
by z7oofy on Jul.13, 2009, under MySQL
If you are trying to restore a large database backup back to your MySQL Server, You know that phpMyAdmin is NOT the best solution for the task, beacause of it’s execution limitaion settings it will reject your file being executed. So one way to archive this is to use the mysql command prompt interface. the syntaxt to back up your database unsing command links is.
mysql -u {UserName} -p {TargetDatabase} < {SourceDumpFile}
{UserName} = Your Database username
{TargetDatabase}= Your Target Databse
{SourceDumpFile}= Your SQL Dump File
once you run the above line correctly. you should be prompt for a password, Enter your database password and continue. (the restoring time depends on the size of your database, so be patient and a grab a coffee if it’s so large.)
ERROR 2006 (HY000) at line 447: MySQL server has gone away
by z7oofy on Jul.13, 2009, under MySQL
If you are getting the error ERROR 2006 (HY000) at line 447: MySQL server has gone away when you are trying to restore any MySQL backup on your command prompt. Try following
Open the my.ini in C:\Windows\ or mysql/bin/my.cnf on XAMPP installation and modify the max_allowed_packet to a higher value. (Probably higher than your backup file size)
TINY INT with LENGTH 1 holds only one BIT
by z7oofy on Jan.05, 2009, under Development, MySQL
Hi, Just wanted to warn about the TINYINT data type on MySQL, just in case if you use TINYINT type with a data length 1, Remember that filed can only hold a one BIT means, the field only can hold 1 OR 0.
Cheers.
ColdFusion CFQUERY character escape issue solved
by z7oofy on Dec.26, 2008, under ColdFusion
Today I was trying this ColdFusion Code, which derived me crazy for about hour, finally I found the solution for the problem. I’ll post this code, so if anybody go through the same, to make it little easy on them. ok here I go..
in my script I used a SQL query looks something like this,
<cfset strSQL=“SELECT * FROM TestTable WHERE test_id=‘xx’”>
<cfquery datasource=“xxxxxx” name=“xxxxxxx” result=“xxxxx” >
#strSQL#
</cfquery>
If you try something like that, it should should pop you a SQL error, if you look the query closely, you would notice that the CFQUERY executes the following command, which we passed in to it.
SELECT * FROM TestTable WHERE test_id=“xx”
you should see that there is a differance between command which get executed and with the one passed in. Means it converts ” ‘ ” character in to ” “ ” this would pop a sql error,
The Reason for this is, CF has it’s automated character escape feature, if you send the above code, CF DOES NOT ESCAPE those characters, But CF Escape any character which are queted with single-quotes,
so the simple solution for the problem is to tell the CF to escape the special characters which are in the command, so this is how we doing to do it.
<cfset strSQL=“SELECT * FROM TestTable WHERE test_id=‘xx’”>
<cfquery datasource=“xxxxxx” name=“xxxxxxx” result=“xxxxx” >
# ‘#strSQL#’ #
</cfquery>
Problem solved, your query should work now..
change date range of JQuery Datepicker
by z7oofy on Nov.20, 2008, under Development, JQuery
here is the code. this will set the datapicker year from 1956 to 2003..
[sourcecode language='javascript']
$(‘#dateofbirth’).datepicker({
yearRange: ’1956:2003′
});[/sourcecode]
How to format date, Jquery UI Datepicker
by z7oofy on Nov.14, 2008, under JQuery
Yes, if you are reading this artical, probably you also must have looking for same thing just like I did few mins ago, well let’s just not keep you searching no more.. so here it is
[sourcecode language='javascript']$(‘#txtDate’).datepicker({
dateFormat: ‘dd/mm/yy’
});[/sourcecode]
on this example I have used European data format (dd/mm/yy) , you can customize your formatting using following parameters. (from JQuery UI documentation)
- d – day of month (no leading zero)
- dd – day of month (two digit)
- D – day name short
- DD – day name long
- m – month of year (no leading zero)
- mm – month of year (two digit)
- M – month name short
- MM – month name long
- y – year (two digit)
- yy – year (four digit)
- ‘…’ – literal text
- ” – single quote

