Home php教程 php手册 windows下PHP 连接不上MYSQL的解决方法

windows下PHP 连接不上MYSQL的解决方法

Jun 13, 2016 am 11:38 AM
mysql php windows Down Not on college Build a website document method of solve connect

 烈火建站学院(Bkjia.Com)文档 PHP连接不上MYSQL.测试连接mysql 提示'Fatal error: Call to undefined function mysql_connect()"环境j是:windows xp sp2 en , apache2.2,mysql5.1rc.php5.28。

 按网易科技的配置教程配置完成后.用phpinfo()查看.没有发现mysql...,但dos窗口中是可以正常操作mysql的.然后.就来回的看看是那里的问题.
在这个网页中http://www.somacon.com/p109.php的所有方法也是

 接着看日志.重装..反复设置php.ini,my.ini,apache.conf,结果还是没追上她..我的脑子真的好难转弯.后来实在是没有什么方法了...就直接用adminphp来看看能不能连上,但提示"Cannot load mysql extension. Please check your PHP configuration".感觉我就是 Mr. bean

 这个提示,会不会是php没有加载到连接mysql的库文件呢? 在启动apache server后.我试着删除'php5ts.dll'和'libmysql.dll'.提示不能删除.说明有程序在用着这两个库文件.说明是有加载的.(当然有许多方法来测试.比如可以用一些软件,查看程序服务加载的所有库文件.也是可以然而ap也说指是php.ini设置有问题.那我就不看别的.我就重点针对php.ini配置.

 在没有迷信php.ini是正确下.终于发现.php.ini中漏了这一行.

 PHPIniDir "你的php目录"
#(例如: PHPIniDir "c:/php")

 重启apache server,然后.用网上常用的方法

以下为引用的内容:
$link=mysql_connect('localhost','用户名','password');
if(!$link) echo "失败!";
else echo "成功!";
mysql_close();
?>

 测试一下.就可以了。我的php.ini配置

 就是这样,花了不少时间了..我也是第一次撞到这个问题.只能说明"缘分''都是"缘分"啊!

 注意:
 同一机器上。如果以前多次安装过.apache.或者安装不是在同一目录.而且不只一个版本.在安装mysql5.1rc前。最好清理一下注册表

 一些别的配置教程.说要复制2个dll文件到system32,其实,按以上163的教程.因为设置了环境变量.,所以就不须要了。如果你以前有复制过.就删除他吧.

以下为引用的内容:
en version:
problem:

if  something wrong with  'Fatal error: Call to undefined function mysql_connect()...' or

'Cannot load mysql extension. Please check your PHP configuration' while your test resolve:
add new line like :
PHPIniDir "#your php root fold"
(e.g: PHPIniDir "c:/php")
in php.ini file
restart servers
see.ok
if unlock its again. link  bellow :
http://www.somacon.com/p109.php
Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1653
14
PHP Tutorial
1251
29
C# Tutorial
1224
24
MySQL and phpMyAdmin: Core Features and Functions MySQL and phpMyAdmin: Core Features and Functions Apr 22, 2025 am 12:12 AM

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

The Compatibility of IIS and PHP: A Deep Dive The Compatibility of IIS and PHP: A Deep Dive Apr 22, 2025 am 12:01 AM

IIS and PHP are compatible and are implemented through FastCGI. 1.IIS forwards the .php file request to the FastCGI module through the configuration file. 2. The FastCGI module starts the PHP process to process requests to improve performance and stability. 3. In actual applications, you need to pay attention to configuration details, error debugging and performance optimization.

How to safely store JavaScript objects containing functions and regular expressions to a database and restore? How to safely store JavaScript objects containing functions and regular expressions to a database and restore? Apr 19, 2025 pm 11:09 PM

Safely handle functions and regular expressions in JSON In front-end development, JavaScript is often required...

Explain the purpose of foreign keys in MySQL. Explain the purpose of foreign keys in MySQL. Apr 25, 2025 am 12:17 AM

In MySQL, the function of foreign keys is to establish the relationship between tables and ensure the consistency and integrity of the data. Foreign keys maintain the effectiveness of data through reference integrity checks and cascading operations. Pay attention to performance optimization and avoid common errors when using them.

SQL vs. MySQL: Clarifying the Relationship Between the Two SQL vs. MySQL: Clarifying the Relationship Between the Two Apr 24, 2025 am 12:02 AM

SQL is a standard language for managing relational databases, while MySQL is a database management system that uses SQL. SQL defines ways to interact with a database, including CRUD operations, while MySQL implements the SQL standard and provides additional features such as stored procedures and triggers.

Compare and contrast MySQL and MariaDB. Compare and contrast MySQL and MariaDB. Apr 26, 2025 am 12:08 AM

The main difference between MySQL and MariaDB is performance, functionality and license: 1. MySQL is developed by Oracle, and MariaDB is its fork. 2. MariaDB may perform better in high load environments. 3.MariaDB provides more storage engines and functions. 4.MySQL adopts a dual license, and MariaDB is completely open source. The existing infrastructure, performance requirements, functional requirements and license costs should be taken into account when choosing.

How does MySQL differ from Oracle? How does MySQL differ from Oracle? Apr 22, 2025 pm 05:57 PM

MySQL is suitable for rapid development and small and medium-sized applications, while Oracle is suitable for large enterprises and high availability needs. 1) MySQL is open source and easy to use, suitable for web applications and small and medium-sized enterprises. 2) Oracle is powerful and suitable for large enterprises and government agencies. 3) MySQL supports a variety of storage engines, and Oracle provides rich enterprise-level functions.

How to efficiently query large amounts of personnel data through natural language processing? How to efficiently query large amounts of personnel data through natural language processing? Apr 19, 2025 pm 09:45 PM

Effective method of querying personnel data through natural language processing How to efficiently use natural language processing (NLP) technology when processing large amounts of personnel data...

See all articles