问题
I'm connected via SSH to my openshift server. I type: env | grep MYSQL
OPENSHIFT_MYSQL_DB_PORT=42361
OPENSHIFT_MYSQL_DB_HOST=XXXXXXX-mydomain.rhcloud.com
OPENSHIFT_MYSQL_DB_PASSWORD=MYPASSWORD
OPENSHIFT_MYSQL_PATH_ELEMENT=/opt/rh/mysql55/root/usr/bin
OPENSHIFT_MYSQL_DB_GEAR_UUID=XXXXXXXXX
OPENSHIFT_MYSQL_DB_USERNAME=MYUSERNAME
OPENSHIFT_MYSQL_DB_URL=mysql://MYUSERNAME:MYPASSWORD@XXXXXX-mydomain.rhcloud.com:42361/
OPENSHIFT_MYSQL_LD_LIBRARY_PATH_ELEMENT=/opt/rh/mysql55/root/usr/lib64
OPENSHIFT_MYSQL_DB_GEAR_DNS=XXXXXXX-mydomain.rhcloud.com
Then, I run
mysql -u $OPENSHIFT_MYSQL_DB_USERNAME -h $OPENSHIFT_MYSQL_DB_HOST -P $OPENSHIFT_MYSQL_DB_PORT -p
and type the exact same password... but I get this error: ERROR 1045 (28000): Access denied for user 'MYUSERNAME'@'10.169.187.123' (using password: YES)
I can't access mysql and my application shows 503 unavailable error (I guess for this reason).
I don't want to lose the data stored inside, so I would like to change password or something.. but since I can't connect to mysql, I can't change the psw like this:
\> set password for 'MYUSERNAME'@'10.169.187.123' = PASSWORD('newpassword');
回答1:
Have you tried accessing the database via the phpMyAdmin page? It should be available under http://.rhcloud.com/phpmyadmin. The credentials for accessing this page are given to you when you create the MySQL cartridge. The default username is 'admin'. If you don't have the admin password anymore, you are of course also out of luck there.
回答2:
You were so close! You need to explicitly specify the MySQL password when you connect.
mysql -u $OPENSHIFT_MYSQL_DB_USERNAME -h $OPENSHIFT_MYSQL_DB_HOST -P OPENSHIFT_MYSQL_DB_PORT --password=$OPENSHIFT_MYSQL_DB_PASSWORD
回答3:
I know the post is old, but I had the same issue and @Tadhg's answer was close. So, I have tried the following in the rhc environment after connecting to rhc ssh <APP_NAME> and it connected me to mysql.
mysql -u $OPENSHIFT_MYSQL_DB_USERNAME -h $OPENSHIFT_MYSQL_DB_HOST --password=$OPENSHIFT_MYSQL_DB_PASSWORD
I have to remove the port as it had error on the port, and it worked. I could not use phpMyAdmin as I get error `phpmyadmin-4 cannot be embedded in scalable app ''.
I hope it helps someone, one day. :)
来源:https://stackoverflow.com/questions/29322474/openshift-cant-connect-to-mysql-from-console