Jump to content

can't access mysql with php setup


Recommended Posts

I have latest stable release of php,apache,mysql but I can't conncect between mysql with php on apache.

I can create a database and tables with command prompt in mysql.

On the php info script test  mysql appears.
I try to access a database with php from mysql.

<?php

$dbhost = 'localhost';

$conn = mysql_connect($dbhost);


$dbname = 'petstore';
mysql_select_db($dbname);
?>


The errors I get is

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Program Files\Apache Group\Apache2\htdocs\myone2.php on line 5

Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Program Files\Apache Group\Apache2\htdocs\myone2.php on line 9

Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in C:\Program Files\Apache Group\Apache2\htdocs\myone2.php on line 9Is my setup wrong?
Link to comment
Share on other sites

q) I don't have a username or password setup and I don't want one either. Where do I effect the username/password?

q)When I do the server instance wizard (mysql)the security part fails on me as it claims port 3363 on is not open and to check the firewall, does this effect php ?
Link to comment
Share on other sites

By defualt MySQL should have  set up a username which is root (which has no password set) during setup. You must have at least one user setup to access the MySQL database, this user will be the admin of the MySQL server.

For your secound question yes. You'll want to open port 3363 in order for queries to be set to the database. Without the port being open PHP will not be able to send any requests to and from the MySQL database.

Also as you are using a port that is not the defualt (3306) you'll need to tell PHP which port your MySQL server is running on. So you'll want to do something like this:
[code=php:0]$conn = mysql_connect('localhost:3363', 'root', '') or die('Unable to connect to MySQL:<br />' . mysql_error());[/code]
The number after 'localhost:' is the port number in which the mysql server is running on.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.