我做了如下
Root User: xxxxxxx Root Password: xxxxxxx Database Name: PHP Connection URL: MysqL://$OPENSHIFT_MysqL_DB_HOST:$OPENSHIFT_MysqL_DB_PORT/
您也可以通过嵌入PHPmyadmin-3.4来管理新的MysqL数据库.
PHPmyadmin用户名和密码将与上面的MysqL凭据相同.
添加了PHPMyAdmin 3.4.请再次记下这些MysqL凭据:
Root User: xxxxxxx Root Password: xxxxxxx URL: https://PHP-doers.rhcloud.com/PHPmyadmin/
$dbh = new PDO('MysqL:host=MysqL://$OPENSHIFT_MysqL_DB_HOST:$OPENSHIFT_MysqL_DB_PORT/;dbname=PHP',"xxxxxx,"xxxxxx");
我不知道连接网址是什么意思?
连接字符串中有一个错误加$OPENSHIFT_MysqL_DB_ *是env变量,需要通过getenv PHP函数获取.
原文链接:https://www.f2er.com/php/140131.html所以尝试以下:
define('DB_HOST',getenv('OPENSHIFT_MysqL_DB_HOST')); define('DB_PORT',getenv('OPENSHIFT_MysqL_DB_PORT')); define('DB_USER',getenv('OPENSHIFT_MysqL_DB_USERNAME')); define('DB_PASS',getenv('OPENSHIFT_MysqL_DB_PASSWORD')); define('DB_NAME',getenv('OPENSHIFT_GEAR_NAME')); $dsn = 'MysqL:dbname='.DB_NAME.';host='.DB_HOST.';port='.DB_PORT; $dbh = new PDO($dsn,DB_USER,DB_PASS);