Wednesday, June 11, 2014

Error establishing a database connection fix

To fix the below error, follow the steps below:


Go to the root directory of wordpress installation and execute the below script to generate the MySQL query.

root@server [/home/clearosa/public_html]# for i in `find -iname wp-config.php` ; do j=$(grep 'DB_NAME' $i | awk -F "'" '{print $4}') ; k=$(grep 'DB_USER' $i | awk -F "'" '{print $4}') ;l=$(grep 'DB_PASSWORD' $i | awk -F "'" '{print $4}') ; echo GRANT ALL PRIVILEGES ON $j.* TO $k@"localhost" identified by "'$l'"";" ; done

Sample Output:

root@meow [/home/kooi/public_html]# for i in `find -iname wp-config.php` ; do j=$(grep 'DB_NAME' $i | awk -F "'" '{print $4}') ; k=$(grep 'DB_USER' $i | awk -F "'" '{print $4}') ;l=$(grep 'DB_PASSWORD' $i | awk -F "'" '{print $4}') ; echo GRANT ALL PRIVILEGES ON $j.* TO $k@"localhost" identified by "'$l'"";" ; done
GRANT ALL PRIVILEGES ON kooid.* TO buhaha@localhost identified by 'koppan';

Now copy the MySQL query and execute it in MySQL prompt to fix this error.


Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Affiliate Network Reviews