Connecting to MYSQL server
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..
newbiecoder
Junior Poster in Training
60 posts since Apr 2009
Reputation Points: 10
Solved Threads: 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.
newbiecoder
Junior Poster in Training
60 posts since Apr 2009
Reputation Points: 10
Solved Threads: 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..
newbiecoder
Junior Poster in Training
60 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
For the record, it's not homework :) I am just trying to learn :)
newbiecoder
Junior Poster in Training
60 posts since Apr 2009
Reputation Points: 10
Solved Threads: 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.
diafol
Rhod Gilbert Fan (ardav)
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080