Surya
Surya

Reputation: 77

Cannot connect to MySQL server on Openshift

Recently, I've started using openshift & also deployed an application using PHP & MySQL. Yesterday, out of curiosity, I've removed the password for phpMyAdmin and guess what, now I'm unable to log in to both phpMyAdmin & mysql database.

I've tried both the passwords (the default one & the empty password) and uninstalled & re-installed the PHPmyAdmin catridge & also, force restarted the app several times but nothing worked. Now, I've no idea what happened. Any help is appreciated.

Upvotes: 1

Views: 2562

Answers (1)

user2879327
user2879327

Reputation:

Hopefully this will help.

I assume what you did was go into phpmyadmin and click on 'users' then 'edit privileges' for one of the users, select 'no password' and hit save right? If so, then I think the following steps should help.

1.) ssh into your gear (you can use the rhc ssh command)
2.) run the mysql command
3.) You should get an error like this ERROR 1045 (28000): Access denied for user 'adminslULJTS'@'127.10.126.130' (using password: YES)
4.) Now, type in the command mysql -u $OPENSHIFT_MYSQL_DB_USERNAME -h $OPENSHIFT_MYSQL_DB_HOST -P $OPENSHIFT_MYSQL_DB_PORT -p
5.) When it asks for a password, just hit enter
6.) You should now be logged into the mysql shell

Now you need to reset your password to what openshift thinks it is.

1.) create another ssh session into your gear in another terminal, leaving the old one open
2.) run the command env | grep MYSQL
3.) this will give you the following information that you will need to reset your password:

OPENSHIFT_MYSQL_DB_HOST=127.10.126.130  
OPENSHIFT_MYSQL_DB_PASSWORD=Il8-rVLIKSrx  
OPENSHIFT_MYSQL_DB_USERNAME=adminslULJTS

Given the above information, go back to your ssh session that had the mysql connection open, and enter the following command:

set password for 'adminslULJTS'@'127.10.126.130' = PASSWORD('Il8-rVLIKSrx');

But you will need to replace the username, host, and password with the ones you got from the above step.

You should now be able to log into phpmyadmin with your old username & password that you can either view using the env | grep MSYQL command, or view in the web console for your application at openshift.com

It also might be worth reviewing this KB article: https://www.openshift.com/kb/kb-e1085-possible-complications-when-changing-your-database-credentials

Upvotes: 5

Related Questions