SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member my_mind's Avatar
    Join Date
    Aug 2006
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question limited new user at mysql with one database

    im sorry if my english is bad,
    example:

    i have account root at linux and i want to create new user at mysql server and create database for my new user.
    new user :alex
    password : made
    database :db_alex

    TO create new user at mysql : alex
    mysql> insert into user values('localhost','alex',password('made'),'Y','Y','Y','Y','Y','N','N','N','Y','Y','N','Y','Y','Y');

    To cresate database at mysql : db_alex
    mysql>create database db_alex;

    Question :
    what script at php and mysql to limited user : alex , to access only one database : db_alex
    user alex can't access other database, except database db_alex.
    user alex can't drop, modyfi and alter other database, except database db_alex.

    this probelm for my is very hard
    thank you for help my

  2. #2
    SitePoint Evangelist ldivinag's Avatar
    Join Date
    Jan 2005
    Location
    N37 33* W122 3*
    Posts
    414
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what version of mysql are you using?

    (actually this should be moved over to the mysql forum)

    reason is that version 4.something moved to a diff set of tables for user ACL...

    if you have a windows machine, download and install the free/open source SQLYOG...

    do the user maintenance from that app...
    leo d.

  3. #3
    SitePoint Member my_mind's Avatar
    Join Date
    Aug 2006
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    im use :
    mysql version
    Ver 11.18 Distrib 3.23.58, for redhat-linux-gnu (i386)

    php
    PHP 4.3.4 (cgi) (built: Apr 7 2004 09:43:47)
    Copyright (c) 1997-2003 The PHP Group
    Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies

    im sorry i don't know what you mean,
    i need php script to solve the probelm...

    thank you
    ------------
    best regrad
    my_mind

  4. #4
    SitePoint Evangelist ldivinag's Avatar
    Join Date
    Jan 2005
    Location
    N37 33* W122 3*
    Posts
    414
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oops... sorry...

    lemme read up on older mysql...

    in the "db" table, that's where you can restrict each user for a certain DB.

    fields are:
    Code:
    host - char 60
    db - char 64
    user - char 16
    select_priv - enum "y", "n"
    insert_priv = "   "
    update_priv = "   "
    delete_priv = "   "
    create_priv = "   "
    drop_priv = "   "
    grant_priv = "   "
    reference_priv = "    "
    index_priv = "    "
    alter_priv = "    "
    so it's similar to the "user" table but you just need to add a "db" column to the sql statement:

    Code:
    INSERT INTO "db" VALUES ("localhost" , "db_alex", "alex", "Y"..."Y");
    remember to put in a value for each PRIV column... also, the user must ALREADY exist in the USER table...
    leo d.

  5. #5
    SitePoint Evangelist ldivinag's Avatar
    Join Date
    Jan 2005
    Location
    N37 33* W122 3*
    Posts
    414
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    btw, there is also another table called "tables_priv" which you can even lock down the user's rights to a particular column in a certain table...

    Code:
    "Host"	"char(60) binary
    "Db"	"char(64) binary
    "User"	"char(16) binary
    "Table_name"	"char(60) binary
    "Grantor"	"char(77)
    "Timestamp"	"timestamp(14)
    "Table_priv"	"set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter')
    "Column_priv"	"set('Select','Insert','Update','References')
    ""
    leo d.


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
  •