0

Hello I installed MYSQL and Apache via XAMPP. And I am trying some codes from a textbook while Apace and MYSQL are running. I am trying to connect MYSQL with this code :

<?php
//connect to MySQL; note we’ve used our own parameters- you should use
//your own for hostname, user, and password
$connect = mysql_connect("localhost", "root", "mysqlpass") or
die ("Hey loser, check your server connection.");
//create the main database
mysql_create_db("wiley")
or die(mysql_error());
....

But I am getting this:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in C:\xampp\test\createmovie.php on line 4
Hey loser, check your server connection.

Could you please tell me how to fix this situation?
Thanks..

4
Contributors
8
Replies
9
Views
6 Years
Discussion Span
Last Post by diafol
0

Did you check to make sure you have a user named "root" with the password "mysqlpass"?

0

No, and I don't know how to check :S and I don't know how to create that user and password on MYSQL either.

0

If you don't have a MySQL user, then how were you planning on connecting to the database?

Google is your friend. Study up a bit, then if you're still having problems, come back here!

0

Thank you very much for helping me.I googled as you advised and I found the command to create user but... I wrote it at the starting of the php part of the code above and I tried something on Command line of Windows but none of them worked. Could you please tell me where to write this command so that a user could be created on MySql
Here is the code I found :

CREATE USER 'root'@'localhost' IDENTIFIED BY 'mysqlpass';

Thank you very much..

0

You have to have some sort of MySQL administration tool. There's something for the Windows Command Line, as well as other tools. Find those, install them, and enter that data in there.

You have to be able to enter queries into MySQL. Do your homework, and you should figure it out.

0

As PG says, try this:

$connect = mysql_connect("localhost", "root", "") or die ("Hey loser, check your server connection.");

AS ballchain says, get an admin tool. Loads of free ones. phpMyAdmin is the usual one, but it can be a bit clunky if you're using it from your own computer. DOwnload and install something like SQLyog (community version) or Navicat (free version) or a plethora of others! This will give you a nicer experience than fiddling with the command line.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.