SitePoint Sponsor

User Tag List

Results 1 to 15 of 15
  1. #1
    SitePoint Member gpaul's Avatar
    Join Date
    May 2004
    Location
    canada
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Access denied MySql

    I have downloaded a pre-configured PHP/MYSql/Apache package for Windows, and everything works well. Can start MySql server and can perform all the queries etc. PHP works well with Apache too. However cannot access MySql from PHP scripts.Get access denied for username@localhost password (YES)etc. Have tried re-setting password etc but no luck. Pretty sure it's a password thing.

    One set of instructions said to write a certain script to bin directory. How do you write to a directory when you can't acces any of the files?

    Can anyone tell me where and how to re-set password so I can access MySql from PHP.

    Can't wait!!

    Glenn

  2. #2
    Free your mind Toly's Avatar
    Join Date
    Sep 2001
    Location
    Panama
    Posts
    2,182
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, the problem is with your password. You need to create a root user.

    Try the following (you can skip the first step if you have already started MySQL service) :

    Code:
    Click Start −> Run and type cmd in the box, click Ok. This will open a console window (or MS−Dos box). In the console
    window enter the following commands and check that you receive the correct response:
    Enter: cd c:\mysql\bin
    Enter: mysqld−max−nt −−install
    Response: Service successfully installed.
    Enter: net start MySql
    Console should say: The MySql service is starting.
    Console should say: The MySql service was started successfully.
    Congratulations you have installed MySQL; however, before we are done here we are going to make MySQL more
    secure, by adding a password, so only you can change the databases.
    At the console window type the following commands (replace new_password with your new password):
    Enter: cd c:\mysql\bin
    Enter: mysql −u root mysql
    Response: Welcome to the MySQL monitor .....
    Enter: UPDATE user SET Password=PASSWORD('new_password')
    Enter: WHERE user='root';
    Response: OK...
    Enter: FLUSH PRIVILEGES;
    Response: OK...
    Enter: DELETE FROM user WHERE user='';
    Response: OK...
    Enter: DELETE FROM user WHERE Host='%';
    Response: OK...
    Enter: DELETE FROM user WHERE User='';
    Response: OK...
    Enter: DELETE FROM db WHERE Host='%';
    Response: OK...
    Enter: exit
    Response: Bye
    Enter: exit
    Response: Console window closes.
    Community Guidelines | Community FAQ

    "He that is kind is free, though he is a slave;
    he that is evil is a slave, though he be a king." - St. Augustine

  3. #3
    SitePoint Member gpaul's Avatar
    Join Date
    May 2004
    Location
    canada
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Access Denied

    Thanks for your input.
    Tried proceedure as suggested...no luck. Still same error message

    ???

    Glenn

  4. #4
    Free your mind Toly's Avatar
    Join Date
    Sep 2001
    Location
    Panama
    Posts
    2,182
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you get any errors while executing those steps? And if you didn't, did you try connecting with the root user after you set up the account?

    PHP Code:
    $db mysql_connect("localhost""root""rootpassword") or die('I cannot connect to the database because: ' mysql_error()); 
    Community Guidelines | Community FAQ

    "He that is kind is free, though he is a slave;
    he that is evil is a slave, though he be a king." - St. Augustine

  5. #5
    SitePoint Member gpaul's Avatar
    Join Date
    May 2004
    Location
    canada
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Access Denied

    Thanks.
    There were no error messages during the steps. Did try to connect afterwards with no success.

    Cannot seem to get back to the config settings in MySql. I may have selected a username other than 'root' during initial set-up, but can't seem to get back to that window.

  6. #6
    Free your mind Toly's Avatar
    Join Date
    Sep 2001
    Location
    Panama
    Posts
    2,182
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by gpaul
    Cannot seem to get back to the config settings in MySql. I may have selected a username other than 'root' during initial set-up, but can't seem to get back to that window.
    What window are you talking about? I'm not sure why it didn't work out for you, it always does.
    Community Guidelines | Community FAQ

    "He that is kind is free, though he is a slave;
    he that is evil is a slave, though he be a king." - St. Augustine

  7. #7
    ..back with a vengeance... Ingoal's Avatar
    Join Date
    May 2002
    Location
    Benningen, Germany
    Posts
    6,260
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Moved to a more appropriate forum....

    Ingo
    Advisor - Community Team
    CHD-magician + + =
    Some of my sites: [1|2|3|4|5|6|7|8|9|10]
    Newest site: ZZ.GD - t dsn't gt mch shrtr thn tht

  8. #8
    SitePoint Member gpaul's Avatar
    Join Date
    May 2004
    Location
    canada
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Access Denied

    Somewhere during first setup, I chose a new username and password. I went into sqlmyadmin, and changed it back to "root" plus my 'new password' in the 'my.ini' file. That is how it remains in there.

    When I tried the proceedure you suggested, I couldn't make it work using the DOS box. I went directly to MySql monitor which was running and chose USE mysql; and made the changes in the 'mysql' database. Perhaps that was not the right thing to do. I couldn't execute the UPDATE commands etc. without first choosing a database.

    I'm trying to connect from PHP script:

    <?php

    mysql_connect("localhost","root","my password");
    ?>

    I'm sure it's a simple thing...just not sure what.

    Thanks

  9. #9
    Free your mind Toly's Avatar
    Join Date
    Sep 2001
    Location
    Panama
    Posts
    2,182
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I wouldn't know how to do it using that method.

    If you can't find a way to make it work, I suggest you uninstall MySQL and reinstall it, and then follow the steps I provided in my first post. Don't do anything through the MySQL GUI until you have set up everything in DOS.
    Community Guidelines | Community FAQ

    "He that is kind is free, though he is a slave;
    he that is evil is a slave, though he be a king." - St. Augustine

  10. #10
    SitePoint Member
    Join Date
    Feb 2003
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I got the same problem , after I read very careffully, It resolved my problem, thank you Toly , just one note I wrote - instead of |
    ex:
    mysqld|max|nt ||install
    mysql |u root mysql

    should be
    mysqld−max−nt −−install
    mysql −u root mysql

  11. #11
    Free your mind Toly's Avatar
    Join Date
    Sep 2001
    Location
    Panama
    Posts
    2,182
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm glad it worked out for you.

    Quote Originally Posted by gonzakad
    mysqld|max|nt ||install
    mysql |u root mysql

    should be
    mysqld−max−nt −−install
    mysql −u root mysql
    Well, I don't see | anywhere on that code. Or did you use another code?
    Community Guidelines | Community FAQ

    "He that is kind is free, though he is a slave;
    he that is evil is a slave, though he be a king." - St. Augustine

  12. #12
    SitePoint Member
    Join Date
    Feb 2003
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you right , I saw that like || using internet explorer 6 but in netscape 7 looks normal , maybe the problems is the browser , for example IE 6 can't see the smilies but in Netscape yes I can, I don't know who or what is wrong with the browser I need to get more ifomation about it.

  13. #13
    SitePoint Wizard
    Join Date
    Jul 2003
    Location
    Corner seat
    Posts
    1,069
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Toly
    Did you get any errors while executing those steps? And if you didn't, did you try connecting with the root user after you set up the account?

    PHP Code:
    $db mysql_connect("localhost""root""rootpassword") or die('I cannot connect to the database because: ' mysql_error()); 
    I get the following error:

    "I cannot connect to the database because: Client does not support authentication protocol requested by server; consider upgrading MySQL client"

    Quite honestly, I have no clue what is going here. What are possible causes for this error?

  14. #14
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What OS are you using btw? Your best bet is to download the latest version of 4 and reinstall it again

    When you uninstall the current version you have, remember to delete the mysql* folder, usually installed under 'Program Files > MySql Server 4.1 > ...'

    Do not try to create your username/password via the configuration process, but as suggested via DOS. What I did was to completely delete the entire contents and just insert a new user altogether, rather than doing an update - I only have the one row in the users table.

  15. #15
    SitePoint Wizard
    Join Date
    Jul 2003
    Location
    Corner seat
    Posts
    1,069
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, it turns out that password needs to be hashed in the old way; more specifically, I needed to use the command old_password to create password. I'm still confused a little, but I kind of decided to move on, as I can do what I need to do for the time being.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •