简体   繁体   English

本地主机上的 mysql_connect()

[英]mysql_connect() on localhost

I am trying to implement a little 'intranet' on my home network, but I am an apache/mysql configuration noob...我正在尝试在我的家庭网络上实现一个小“内部网”,但我是一个 apache/mysql 配置菜鸟......

Running fedora 10, and have apache, mysql, and php set up as well as i know how.运行 fedora 10,并设置了 apache、mysql 和 php,我知道如何设置。 However, when I try using a standard form with POST, the php script seems to error out on the mysql_connect(...);但是,当我尝试使用带有 POST 的标准表单时,php 脚本似乎在 mysql_connect(...); 上出错了。 line.线。 I don't get an error message, in fact the browser page is blank, even in the view source window.我没有收到错误消息,实际上浏览器页面是空白的,即使在查看源 window 中也是如此。 Here is what I have:这是我所拥有的:

$conn = mysql_connect("localhost:1186", "user", "password");

...

I have added the username and password in the mysqladmin tool, and i've tried "localhost" and "localhost:1186", as I saw the 1186 port referenced in my my.cnf file.我已经在 mysqladmin 工具中添加了用户名和密码,并且我尝试了“localhost”和“localhost:1186”,因为我看到了 my.cnf 文件中引用的 1186 端口。

Obviously I have something configured wrong, any ideas?显然我有一些配置错误,有什么想法吗?

The resulting page is blank when there's an error.出现错误时,结果页面为空白。 One of the more common errors to make in your setup is to forget to install either the php-mysql or mysql-server packages.设置中最常见的错误之一是忘记安装 php-mysql 或 mysql-server 软件包。 Verify that they're installed, and if not install either or both and then restart the httpd service, and start the mysql service if not running.验证它们是否已安装,如果未安装其中一个或两个,则重新启动 httpd 服务,如果未运行则启动 mysql 服务。

the default for a fresh mysql install would be全新 mysql 安装的默认设置为

$conn = mysql_connect("localhost:3306", "root", ""); $conn = mysql_connect("localhost:3306", "root", "");

or just要不就

$conn = mysql_connect("localhost", "root", ""); $conn = mysql_connect("localhost", "root", "");

This is good for testing purposes but leaving the root account unprotected is a bad habit.这有利于测试目的,但让 root 帐户不受保护是一个坏习惯。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM