MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old August 16th, 2003, 12:52 PM
pentapenguin pentapenguin is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 51 pentapenguin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 7 sec
Reputation Power: 6
Strange MySQL Access Problem

First some basic info:
OS: Windows XP
Server: Microsoft-IIS/5.1
PHP: 4.3.2
MySQL: 4.0.13

Problem:
I can work with MySQL via the command line just fine.
(I can create databases, select info, etc.)
However, whenever I try to open a connection with it in PHP, I always get the following error:
"Access denied for user: 'root@127.0.0.1' (Using password: YES)"
Here's the connection string:
PHP Code:
 $connection mysql_connect("localhost""root""password") or die ("Unable to connect to MySQL - " mysql_error());
mysql_select_db($database_dbname) or die ("Unable to select database: $db - " mysql_error()); 

I do have the same username/password combo entered in the "my.ini" file.

Here's the "my.ini" file: (MySQL was installed in default directory)
---------------------------------------------------
#This File was made using the WinMySQLAdmin 1.4 Tool
#8/16/2003 12:52:20 PM

#Uncomment or Add only the keys that you know how works.
#Read the MySQL Manual for instructions

[mysqld]
basedir=C:/mysql
#bind-address=169.254.101.152
datadir=C:/mysql/data
#language=C:/mysql/share/your language directory
#slow query log#=
#tmpdir#=
#port=3306
#set-variable=key_buffer=16M
[WinMySQLadmin]
Server=C:/mysql/bin/mysqld-nt.exe
user=root
password=password
---------------------------------------------------
So, what's the problem?!?

Also, when I try to use the MySQL Control Center I get the same error.
{[localhost] ERROR 1045: Access denied for user: 'root@127.0.0.1' (Using password: YES)}

Would somebody PLEASE help me?
I've spent hours serching the manuals, Google, etc.
THANKS!

Last edited by pentapenguin : August 16th, 2003 at 11:00 PM.

Reply With Quote
  #2  
Old August 16th, 2003, 09:16 PM
iahmed iahmed is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Location: USA
Posts: 171 iahmed User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 58 sec
Reputation Power: 6
So, you are planning to use IIS as your web server?

Did you configure IIS properly to run php scripts?

Yor codes are absolutely error free.

However, you can also check the correctness of your script in the following way.

1. CD to PHP folder

>php.exe YourScript.php

Reply With Quote
  #3  
Old August 16th, 2003, 10:59 PM
pentapenguin pentapenguin is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 51 pentapenguin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 7 sec
Reputation Power: 6
Thanks for replying.
Yes, PHP is working fine.
I have tons of other pages and "phpinfo.php" as well -- all work great!
Like I said, MySQL works just fine through the command line *only.*
No PHP support.
I didn't know about running PHP directly from the command line though....

Reply With Quote
  #4  
Old August 17th, 2003, 03:15 AM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
Lets have you log into mysql from the command line, switch to the 'mysql' database, and issue the following command:

select host,user from user;

Also, please post the command (exactly as you would type it) you use on the command line to access mysql.
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #5  
Old August 17th, 2003, 11:23 AM
wastedbreath wastedbreath is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: BC, Canada
Posts: 35 wastedbreath User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to wastedbreath
I'm pretty much a beginner at MySQL, but have you added the user to the database..or is that what laidbak just told you?

Reply With Quote
  #6  
Old August 17th, 2003, 05:19 PM
pentapenguin pentapenguin is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 51 pentapenguin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 7 sec
Reputation Power: 6
------------------------------------------------------------------------------------
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Jeremy>cd c:\mysql\bin

C:\mysql\bin>mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 4.0.13-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> USE mysql;
Database changed
mysql> SELECT host,user FROM user;
+-----------+------+
| host | user |
+-----------+------+
| % | |
| % | root |
| localhost | |
| localhost | root |
+-----------+------+
4 rows in set (0.05 sec)

mysql>
------------------------------------------------------------------------------------

The two users were already in the table when I set MySQL up.
Let me know what you think.

Reply With Quote
  #7  
Old August 17th, 2003, 11:21 PM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
| % | |
| % | root |
| localhost | |
| localhost | root |
+-----------+------+

Ok, where is what you need to do... login as root... right now you are logging in anonymously.

mysql -u root -p

Reply With Quote
  #8  
Old August 18th, 2003, 09:42 PM
pentapenguin pentapenguin is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 51 pentapenguin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 7 sec
Reputation Power: 6
Thanks for replying.
Unfortuantly, it didn't work.
Here's what happened.
------------------------------------------------------------------------------------
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Jeremy>cd c:\mysql\bin

C:\mysql\bin>mysql -u root -p
Enter password: ********
ERROR 1045: Access denied for user: 'root@127.0.0.1' (Using password: YES)

C:\mysql\bin>
------------------------------------------------------------------------------------

I did type the password correctly (actually did it twice), and I still get that "1045" error.

Some other thing I tried:
(All of my scripts worked fine on another XP machine with a little older version of MySQL.)
I uninstalled the current version of MySQL and put the same version that worked on the other machine on.
That didn't work either.
Does anyone think that there's a problem with my new machine?

Reply With Quote
  #9  
Old August 18th, 2003, 10:42 PM
iahmed iahmed is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Location: USA
Posts: 171 iahmed User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 58 sec
Reputation Power: 6
Plz try following, it may take 5-10 minutes

01. Keep a backup of your databases from folder c:\mysql\data
02. Shutdown the database (NET STOP MYSQL)
03. Uninstall MySQL
04. Manually delete C:\MySQL folder
05. Re-install MySQL and copy your database back to c:\mysql\data folder

After above steps you have a user root with nopassword.

This will work and you can save your time.

Do you have MySQL Front? If you need it, please let me know, I can give you a copy (its a free software).
Thanks

Reply With Quote
  #10  
Old August 19th, 2003, 11:50 AM
pentapenguin pentapenguin is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 51 pentapenguin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 7 sec
Reputation Power: 6
Hi.

I don't have MySQL Front, so a link would be appreciated.
I tried the EXACT steps you said, but I can't access MySQL (on the command line) until I run the "winmysqladmin.exe" program in the C:\mysql\bin" directory.
I'm propmted to enter a username and password.
Once I do that, I can access MySQL on the command line.
(I guess it sets up the "my.ini" file.)

As for there's no password, look at the "user" table info I posted above.

Evough though it isn't working yet, THANKS GUYS!

Reply With Quote
  #11  
Old August 19th, 2003, 02:15 PM
iahmed iahmed is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Location: USA
Posts: 171 iahmed User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 58 sec
Reputation Power: 6
Probabbly MySQL didnt run as service, thats why you had to force it by WinMysQLAdmin.exe.

Let me know your email, I will send one to u (coz' MySQL Font is no longer in Bussiness) and they have no web site now too.

Reply With Quote
  #12  
Old August 19th, 2003, 04:47 PM
pentapenguin pentapenguin is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 51 pentapenguin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 7 sec
Reputation Power: 6
My email is jeremy_conley@hotmail.com
Thanks

Reply With Quote
  #13  
Old August 20th, 2003, 01:15 AM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
1. You need to first shut down mysql

2. You need to restart mysql without the grant tables
( use this command line switch : --skip-grant-tables )

3. Now when you login with the command : "mysql -u root -p" you should have no problem.

4. Now that you are in, change the root password

5. Delete all user accounts with a blank password
DELETE FROM user WHERE password='';

6. issue command : flush-privileges

7. Logout, then login with your new root password.

Reply With Quote
  #14  
Old August 20th, 2003, 01:17 PM
pentapenguin pentapenguin is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 51 pentapenguin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 7 sec
Reputation Power: 6
Hi.
Just to make sure I'm with you (and don't mess anything else up further), I'll use the following commands:
Quote:
1. You need to first shut down mysql

("NET STOP MySQL" and then "mysqld --remove" ?)

Quote:
2. You need to restart mysql without the grant tables
( use this command line switch : --skip-grant-tables )

("mysql --skip-grant-tables" or something else?)

Quote:
3. Now when you login with the command : "mysql -u root -p" you should have no problem.

(OK)

Quote:
4. Now that you are in, change the root password

("UPDATE user SET password='password' WHERE user='root' OR use "mysqladmin -u root password 'password' "?)

Quote:
5. Delete all user accounts with a blank password
DELETE FROM user WHERE password='';

(OK)

Quote:
6. issue command : flush-privileges

("mysqladmin flush-privileges" ?)

Quote:
7. Logout, then login with your new root password.

("exit" then "mysql" ?)

Reply With Quote
  #15  
Old August 20th, 2003, 02:48 PM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
Quote:
("NET STOP MySQL" and then "mysqld --remove" ?)
You don't need to remove mysqld from the services, just stopping it is enough.

Reply With Quote
  #16  
Old August 20th, 2003, 02:49 PM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
Quote:
mysql --skip-grant-tables" or something else
mysqld --skip-grant-tables

Reply With Quote