Home >Database >Mysql Tutorial >Bae PHP环境怎么配置配置Mysql

Bae PHP环境怎么配置配置Mysql

WBOY
WBOYOriginal
2016-06-07 16:37:411006browse

/*替换为你自己的数据库名(可从管理中心查看到)*/ $dbname = 'MCpLBnaTwQudcCVdIeCa'; /*从BAE环境变量里取出数据库连接需要的参数*/ $host = getenv(HTTP_BAE_ENV_ADDR_SQL_IP); $port = getenv(HTTP_BAE_ENV_ADDR_SQL_PORT); $user = getenv(HTTP_BAE_EN

<br> /*替换为你自己的数据库名(可从管理中心查看到)*/<br> $dbname = 'MCpLBnaTwQudcCVdIeCa';

/*从BAE环境变量里取出数据库连接需要的参数*/
$host = getenv(‘HTTP_BAE_ENV_ADDR_SQL_IP’);
$port = getenv(‘HTTP_BAE_ENV_ADDR_SQL_PORT’);
$user = getenv(‘HTTP_BAE_ENV_AK’);
$pwd = getenv(‘HTTP_BAE_ENV_SK’);
$dbconfig = array(
//数据库配置信息
‘DB_TYPE’ => ‘mysql’, // 数据库类型
‘DB_HOST’ => $host, // 服务器地址
‘DB_NAME’ => $dbname, // 数据库名
‘DB_USER’ => $user, // 用户名
‘DB_PWD’ => $pwd, // 密码
‘DB_PORT’ => $port, // 端口
‘DB_PREFIX’ => ‘tenking_’, // 数据库表前缀

);

关键是通过环境变量来获取mysql的相关配置信息

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn