windows平台如何在xampp中激活mysql数据库?

问题描述:

我已经在我的 Windows XP 上安装了 XAMPP.我启动了 XAMPP 控制面板,它显示 apache 和 mysql 正在运行.

I've installed XAMPP on my Windows XP. I started the XAMPP control panel and it shows apache and mysql are running.

当我通过 localhost/xampp 检查状态时,它显示:

When I check the status by going to localhost/xampp it shows:

mysql : deactivated

当我运行访问mysql数据库的php文件时,显示如下错误:

When I run php files that access the mysql database, it shows the following errors:

Warning: mysql_connect() [function.mysql-connect]: [2002] No connection could 
be made because the target machine actively refused it. (trying to connect 
via tcp://localhost:3306) in C:\xampp\htdocs\Elo_algorithm.php on 
line 18

我已经浏览了 XAMPP 故障排除页面和常见问题解答,但我不知道该怎么做.XAMPP 控制面板显示 mysql 正在运行,但 xampp 状态显示:deactivated.

I've been through the XAMPP troubleshooting page and FAQ but I don't understand what to do. The XAMPP control panel shows mysql is running, but xampp status shows: deactivated.

这里发生了什么?

你应该在xampp安装中查看文件\xampp\mysql\data\mysql_error.log".

You should view in the xampp installation the file "\xampp\mysql\data\mysql_error.log".

此文件包含 MySQL 的错误日志,您可以在其中检测任何问题,例如 por in use.

This file contais the error log of MySQL and in it you can detect any problem like por in use.

例如,这行日志显示端口3306(mysql默认)被另一个应用程序使用,无法访问.

For example, this lines of log show that the port 3306 (the mysql default) is used by another application and can't be accessed.

111130  8:39:56 [ERROR] Can't start server: Bind on TCP/IP port: No such file or directory
111130  8:39:56 [ERROR] Do you already have another mysqld server running on port: 3306 ?
111130  8:39:56 [ERROR] Aborting

如果 MySQL 中的所有内容都正确,则问题可能与 php 应用程序中的驱动程序有关.目前 PHP 有两种 MySQL 连接器类型,mysql"和mysqli",MySQLmysql"连接器,它们使用mysql_"(您用于连接的方法是 mysql_connect)前缀函数, 用于旧的 MySQL 4 应用程序以及当 MySQL 5.x if 配置了旧密码"参数时.mysqli"用于新的 mysql 5.x 版本,在 php 中你必须使用mysqli_"前缀函数,如mysqli_connect".

If all in the MySQL is correct probably the problem is related to the driver in the php application. Currently PHP has two MySQL connector types, the "mysql" and the "mysqli", MySQL "mysql" connector, that use "mysql_" (the method that you are using to connect is mysql_connect) prefixed functions, is used for old MySQL 4 applications and when the MySQL 5.x if is in configured with the "old password" parameter. The "mysqli" is used for the new mysql 5.x versions and in php you must use "mysqli_" prefixed functions like "mysqli_connect.

最新版本的 xampp 使用的版本是 MySQL 5.5,您需要使用 mysqli 连接器.

The version used by the lastest versions of xampp is MySQL 5.5 and you require to used the mysqli connector.