apache php 5.3.1 的 phpinfo() 中未启用 mysql
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2198154/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
mysql is not enabled in phpinfo() of php 5.3.1
提问by MB.
I am having apache 2.2.14, php 5.3.1 and mysql 5.1.43 installed on vista. I am trying since 2 days to configure php to have mysql enable on phpinfo().
我在 vista 上安装了 apache 2.2.14、php 5.3.1 和 mysql 5.1.43。我从 2 天开始尝试配置 php 以在 phpinfo() 上启用 mysql。
- I modified php.ini to have extension_dir = "c:\php\ext"
- modified the extension as extension="php_mysql.dll"
- added "c:\php" to the "PATH" environment variable and restarted the vista.
- 我将 php.ini 修改为 extension_dir = "c:\php\ext"
- 将扩展名修改为 extension="php_mysql.dll"
- 将“c:\php”添加到“PATH”环境变量并重新启动vista。
after trying many combinations of putting php.ini, php_mysql.dll and libmysql.dll in c drive and/or c:/windows and/or c:/windows/system32 now I am with no options!!
在尝试了将 php.ini、php_mysql.dll 和 libmysql.dll 放在 c 驱动器和/或 c:/windows 和/或 c:/windows/system32 中的多种组合之后,我现在别无选择!!
I do restart the apache after each modification. I used libmysql.dll present in mysql installation and that of older php version as php 5.3.1 has no libmysql.dll...
每次修改后我都会重新启动apache。我使用了 mysql 安装中存在的 libmysql.dll 和旧 php 版本的 libmysql.dll,因为 php 5.3.1 没有 libmysql.dll ...
Any help will be appreciated. Thanks in advance.
任何帮助将不胜感激。提前致谢。
回答by dododedodonl
You have to edit php.ini and add/uncomment a line to import the php_mysql.dllextention. Search for ;extention=php_mysql.dlland remove the ;. If you find this line without the ;in front of it, you have another problem. If you don't find this line, add it without the ;.
您必须编辑 php.ini 并添加/取消注释一行以导入php_mysql.dll扩展名。搜索;extention=php_mysql.dll并删除;. 如果你发现这条线;前面没有,那你就有另一个问题了。如果您没有找到这一行,请在不带;.
You can also try to put a \after the extention path: extension_dir="c:\php\ext\"
您也可以尝试\在扩展路径之后放置一个:extension_dir="c:\php\ext\"
回答by Dan Beam
put php_mysql.dll in the "c:\php\ext" directory (and keep the extension="php_mysql.dll"uncommented [without the leading ;])
将 php_mysql.dll 放在 "c:\php\ext" 目录中(并保留未extension="php_mysql.dll"注释的 [没有前导;])
回答by VolkerK
Make sure you've edited the right php.ini. In case of doubt
确保您编辑了正确的 php.ini。如有疑问
<?php echo 'ini= "', get_cfg_var('cfg_file_path'), '"';
will tell you which one is used by your php installation.
会告诉您 php 安装使用的是哪一个。
Maybe php tried to load the php-mysql extension and failed because of additional dependencies. That would cause a startup error entry in the error.log.
也许 php 尝试加载 php-mysql 扩展并失败,因为额外的依赖。这将导致error.log 中出现启动错误条目。
Which php-build do you use? The php-mysql extension can either use libmysql.dll as transport layer or the new mysqlnd (MySQL native driver)module. You've added c:\php to PATH. That's usually done in order to let windows find libmysql.dll (though it's not necessary, there are other methods which I prefer). If php-mysql depends on libmysql.dll and windows can't find it loading php_mysql.dll will fail.
But if you're using the php.net build of php 5.3.1 the mysql module uses mysqlnd:
你使用哪个 php-build?php-mysql 扩展可以使用 libmysql.dll 作为传输层,也可以使用新的mysqlnd(MySQL 本地驱动程序)模块。您已将 c:\php 添加到 PATH。这样做通常是为了让 Windows 找到 libmysql.dll(虽然这不是必需的,但我更喜欢其他方法)。如果 php-mysql 依赖于 libmysql.dll 并且 windows 找不到它,则加载 php_mysql.dll 将失败。
但是如果你使用 php.net 构建的 php 5.3.1 mysql 模块使用 mysqlnd:
Installation on WindowsIn the official PHP distributions from 5.3 onwards, MySQL Native Driver is enabled by default
在 Windows 上安装该模块内置在 php.net 构建中。您可以通过调用5.3 以后的官方 PHP 发行版中,默认启用 MySQL Native Driver
php -mphp -m命令外壳来测试它。它打印所有内置模块。回答by Mohamed Arabi
Thanks a lot to the user who said that we have to move the file php.inito the folder /binof the Apache server. it resolves me the same problem after more than one week of trying failed methods.
非常感谢用户说我们必须将文件移动php.ini到/binApache服务器的文件夹中。经过一个多星期的尝试失败的方法后,它为我解决了同样的问题。
Of course we must uncomment in the file the two lines;
当然,我们必须在文件中取消注释这两行;
;extension=php_mysql.dll
;extensin_dir="ext"
by removing the semi-colon (;) and by specifying the full path for the extension library php_mysql.dllrather than extas follows
通过删除分号 ( ;) 并指定扩展库的完整路径php_mysql.dll而不是ext如下
extension=php_mysql.dll
extensin_dir="c:\Apache22\php53\ext"
For me I installed Apache in the folder c:\Apache22and PHP in the folder c:\Apache22\php53, you must use your own values.
对我来说,我在文件夹中安装了 Apache,在文件夹中安装了c:\Apache22PHP c:\Apache22\php53,您必须使用自己的值。
NOTE: Because mysql_functions like mysql_connect()become deprecated in PHP 5.5 and above, it is recommended to enable also the library php_mysqli.dllto use functions like mysqli_(improved version of mysql_functions). To do that it is simple, you just have to uncomment the line:
注意:由于PHP 5.5 及以上版本已弃用mysql_类似函数mysql_connect(),因此建议也启用库php_mysqli.dll以使用类似函数mysqli_(函数的改进版本mysql_)。要做到这一点很简单,您只需要取消注释该行:
;extension=php_mysqli.dll
in the file PHP.ini as follows:
在文件 PHP.ini 中,如下所示:
extension=php_mysqli.dll
回答by Austin
Update April 7, 2013. Installed Windows 8 on an i7 Quad, HT 8, 3.62GHz, 12GBRAM.. Installed the latest version of MySQL, got it functioning properly. Installed the latest version of Apache Web Server, got it functioning properly. Installed the latest version of PHP, got it functioning properly. MySQL could not connect to the database. The error message was "mysql_connect function undefined". I copied the modified php.ini file into the "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin", and restarted Apache web server... then it all magically started working.!!! I hope this helps somebody with setting up their own Windows MySQL / PHP web server.
2013 年 4 月 7 日更新。在 i7 Quad、HT 8、3.62GHz、12GBRAM 上安装了 Windows 8。安装了最新版本的 MySQL,使其正常运行。安装了最新版本的 Apache Web Server,使其正常运行。安装了最新版本的 PHP,使其正常运行。MySQL 无法连接到数据库。错误消息是“mysql_connect 函数未定义”。我将修改后的 php.ini 文件复制到“C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin”中,然后重新启动 Apache Web 服务器……然后一切就神奇地开始工作了。!!!我希望这有助于有人设置他们自己的 Windows MySQL/PHP Web 服务器。

