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.

 

the_content not responding to the “more tag” outside of WP

April 14th, 2011

when used setup_postdata() , the_content ignore more tag

the more tag does not work on custom queries like that.

You can set the global $more variable to either 1 or 0 to turn the more functionality on or off. Do this right before your call to the content:

global $more;
$more = 1;
the_content();

0 means turn on
1 means turn off

 

print web page without showing print dialogbox

March 14th, 2011

Here’s what you need to do to enable Firefox immediately print without showing the print preferences dialog box.

  1. Type about:config at Firefox’s location bar and hit Enter.
  2. Right click at anywhere on the page and select New > Boolean
  3. Enter the preference name as print.always_print_silent and click OK.

For IE

function printit(){
if (window.print) {
window.print() ;
} else {
var WebBrowser = ‘<OBJECT ID=”WebBrowser1″ WIDTH=0 HEIGHT=0 CLASSID=”CLSID:8856F961-340A-11D0-A96B-00C04FD705A2″></OBJECT>’;
document.body.insertAdjacentHTML(‘beforeEnd’, WebBrowser);
WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = “”;
}
}

 

Joomla Component Install – Unable to Find Install Package

February 10th, 2011

Symptoms:

Joomla 1.5 fresh install was working fine and was able to install and uninstall mods, extensions templates, etc. just fine. After a few days of set up,  modifying my templates and adjusting my Global Settings, I was not able to upload any modules, extensions, templates, etc. and continuously received the ‘Unable to Find Install Package’. This was not a legacy issue.

The Solution:

During my setup, I had enabled my FTP but later turned it off in my Global Settings. However, what I discovered was that my FTP was not actually ‘turning off’. When I would deactivate it, and save my settings, the next time that I logged into my Global Settings, it would be back on. To resolve this, I went directly into my configuration.php file and manually adjusted the FTP settings.

var $ftp_enable = ‘0′;
var $ftp_host = ”;
var $ftp_port = ”;
var $ftp_user = ”;
var $ftp_pass = ”;
var $ftp_root = ”;

So, in short — try adjusting your FTP settings directly in your configuration.php file.

I hope this helps someone else!

Details by

Miss Vicky

 

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