test

October 27th, 2012

 

Delete file ‘mysql-bin.0000xx’

May 1st, 2012

mysql-bin.0000xx are binary log files. The binary log is a set of files that contain information about data modifications made by the MySQL server. The log consists of a set of binary log files, plus an index file.

To remove these files use purge command

PURGE BINARY LOGS TO 'mysql-bin.010'; -- delete all files created before here specified file
PURGE BINARY LOGS BEFORE '2008-04-02 22:46:26'; -- delete all files created before date and time specified here

 

mysql database backup – multiple database in seperate files

March 2nd, 2012
reference: http://www.snowfrog.net/2005/11/16/backup-multiple-databases-into-separate-files/

#!/bin/bash
# sonia 16-nov-05
# backup each mysql db into a different file, rather than one big file
# as with --all-databases - will make restores easier

USER="root"
PASSWORD="secret"
OUTPUTDIR="/var/lib/bacula"
MYSQLDUMP="/usr/bin/mysqldump"
MYSQL="/usr/bin/mysql"

# clean up any old backups - save space
rm "$OUTPUTDIR/*gz" > /dev/null 2>&1

# get a list of databases
databases=`$MYSQL --user=$USER --password=$PASSWORD \
 -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`

# dump each database in turn
for db in $databases; do
    echo $db
    $MYSQLDUMP --force --opt --user=$USER --password=$PASSWORD \
    --databases $db | gzip > "$OUTPUTDIR/$db.gz"
done

 

Recover MySQL root Password

December 7th, 2011

to recover MySQL database server password use following five easy steps

Step # 1: Stop the MySQL server process.

Step # 2: Start the MySQL (mysqld) server/daemon process with the –skip-grant-tables option so that it will not prompt for password.

Step # 3: Connect to mysql server as the root user without password.

Step # 4: Setup new mysql root account password i.e. reset mysql password.

Step # 5: Exit and restart the MySQL server.

Here are commands you need to type for each step (login as the root user):

Step # 1 : Stop mysql service

# /etc/init.d/mysql stop

Step # 2: Start to MySQL server w/o password:

# mysqld_safe --skip-grant-tables &

or

# mysqld --skip-grant-tables

Step # 3: Connect to mysql server using mysql client:

# mysql -u root

Step # 4: Setup new MySQL root user password

mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit

Step # 5: Stop MySQL Server:

# /etc/init.d/mysql stop

Step # 6: Start MySQL server and test it

# /etc/init.d/mysql start
# mysql -u root -p

 

Disable WordPress 3.1 admin bar for all users except admin

August 9th, 2011
function my_function_admin_bar($content) {
return ( current_user_can("administrator") ) ? $content : false;
}
add_filter( 'show_admin_bar' , 'my_function_admin_bar');

Reference: http://www.binbert.com/blog/2011/03/disable-wordpress-3-1-admin-bar-for-all-users-except-admin/

 

codeignitor IE session problem

June 3rd, 2011

was facing same problem of session with IE 8. Many threads suggested for underscore, timezone difference. Real problem is timezone difference. CI creates cookie with server time and IE checks expiry related to client timezone. And here issues comes. You can not change time zone of online server to match clients from all over world. The better solution is change cookie / session expiry time. By default it is two hours. Change it to 24 hours and problem will be solved.

In config.php file change value of following variable

from two hours

$config[‘sess_expiration’]      = 7200;

to 24 hours

$config[‘sess_expiration’]      = 3600 * 24;

 

codeigniter Class ‘MY_Controller’ not found

June 1st, 2011

If you are using codeigniter 2.0 and getting following error

Fatal error: Class ‘MY_Controller’ not found in application\controllers\welcome.php on line 4

then reasons can be

1. you are either not loading it properly (via an __autoload() or manually using include())

2. it is in the wrong place.

In CI 2.0 MY_Controller should be in application/core. In previous version it should be in application/library

 

jquery autocomplete wrong position

May 24th, 2011

jQuery autocomplete is very good tool. It works very well. The autocomplete drop down shows below textbox. But I faced issue when a fixed width assigned to body.
I fixed width of body in stylesheet as body{width:900px;} and it created issue for autocomplete. Autocomplete drop down has been placed some where else from the targetted text box.
To solve the problem I implemented following solution and it is working fine.

Edit jquery.autocomplete.js file.

find following code
show: function() {
var offset = $(input).offset();

this code is at around 702 line number

Add following code just below the code you found

var screenWidth = screen.width;
var bodyWidth = $(“body”).width();
if (screenWidth > bodyWidth)
{
var diff = (screenWidth – bodyWidth)/2;
offset.left = offset.left – diff;
}

With this code now jquery autocomplete drop down positioned horizontally properly even if width of the body is fixed. With 100% width there is no problem .

 

__PHP_Incomplete_Class Errors

May 5th, 2011

If you get such a error That means class not defined before starting session.

If classes stored  in a session you must define your class before the call to session start().

If you have  in configuration session auto_start = 1, you will have to disable that so you can define your classes before starting the session.

Another easiest workaround is to define  __autoload() function before session start(). This way the appropriate classes are loaded when needed and it will solve the error. also you do not need to make any changes in configuration file

 

wordpress sort posts by custom field numeric value

April 14th, 2011

there is no default option in wordpress to set up sort order of post manually while adding post. Other options are sorting by title or date using query_post() function.  To set up custom sort order we can do this using custom field. Use following code

query_posts(orderby=meta_value&meta_key=sort_order&order=ASC’);

REMEMBER: if you use this function then you have to assign sort_order custom field to each post. Otherwise posts which do not have sort_order custom field will not be displayed.

 

Site map | Blog
Copyright © 2008, COG IT Solutions Pvt. Ltd. All Rights Reserved
XHTML Validated