SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2004
    Location
    united states
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    granting a user the right to connect to a database

    Hello

    I have a local mysql server (MySQL 5.0)
    I would like to create a new database in the server (called app) and to create a user account that will have the right to connect to that database.

    I running the following code in order to set up the account:
    PHP Code:
    // create the new database:
    $connection mysql_connect("localhost""root"""MYSQL_CLIENT_COMPRESS);
    mysql_query("CREATE DATABASE IF NOT EXISTS app;"$connection);

    // set up the second account:
    mysql_query("GRANT LOCK TABLES, SELECT, UPDATE, INSERT ON app.* TO 'user'@'%' identified by 'password';"$connection);
    mysql_query("GRANT LOCK TABLES, SELECT, UPDATE, INSERT ON app.* TO 'user'@'localhost' identified by 'password';"$connection);
    mysql_query("FLUSH PRIVILEGES;"$connection); 
    Next I try to perfrom the following code:
    PHP Code:
    $connection mysql_connect("localhost""user""password"MYSQL_CLIENT_COMPRESS); 
    But I get the following error:
    Client does not support authentication protocol requested by server; consider upgrading MySQL client

    Is this the right way to create an account?
    Why is the code failing?
    I am trying to connect from the localhost to the server.
    thanks in advance

  2. #2
    SitePoint Zealot
    Join Date
    Mar 2004
    Location
    united states
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have set the following as well, as recommended in the manual:
    PHP Code:
    mysql_query("SET PASSWORD FOR 'user'@'localhost' = OLD_PASSWORD('password');"
    Now when I try to connect to the server I get the following error:
    Access denied for user: 'user'@'localhost' to database 'app'

    help is appreciated


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
  •