Results 1 to 7 of 7

Thread: Creating db

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2004
    Location
    Canada
    Posts
    95

    Creating db

    Im using mysql for a db server. I am wonering what the query would be to create a database and assign it a username and password using sql if possible.


    Thanks,

  2. #2
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Creating db

    Have a look at this, it may help you

    Cheers,

    RyanJ
    My Blog.

    Ryan Jones.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2004
    Location
    Canada
    Posts
    95

    Re: Creating db

    Thats not really what i was looking for, but thanks anyways. I know how to create a db, but when i do it has no username or password set for it. What i want to do is be able to set a username and password for the database when i create it.

  4. #4
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Creating db

    Ah, Sorry I miss-understood your question.

    I don't think this is possible in PHP, if it were then you could create / edit databases through PHP at will and this could pose some security risks.


    Cheers,

    RyanJ
    My Blog.

    Ryan Jones.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 2004
    Location
    Canada
    Posts
    95

    Re: Creating db

    Quote Originally Posted by sciguyryan
    Ah, Sorry I miss-understood your question.

    I don't think this is possible in PHP, if it were then you could create / edit databases through PHP at will and this could pose some security risks.
    Yeah, i guess i was kinda thinking more along the lines of doing it in SQL. Im sure there has got to be a way of doing it.

  6. #6
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Creating db

    You can create a database in PHP and set permissions on it, as long as you have loggied in as the root mysql user or as a user with priviledges to grant permissions on a database.

    Make sure that you have used mysql_select_db('MySql') before executing this query using the mysql_query() function.
    Code:
    GRANT ALL ON dbname.* TO 'username'@'hostname' IDENTIFIED BY 'password';
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  7. #7
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Creating db

    Thats interesting to know, thanks for the correction visualAd


    Cheers,

    RyanJ
    My Blog.

    Ryan Jones.

Posting Permissions

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



Click Here to Expand Forum to Full Width