×
Create a new article
Write your page title here:
We currently have 3,189 articles on s23. Type your article name above or create one of the articles listed here!



    s23
    3,189Articles

    MySQL/Create User: Difference between revisions

    Content added Content deleted
    No edit summary
    imported>mutante
    mNo edit summary
     
    (3 intermediate revisions by 3 users not shown)
    Line 1: Line 1:
    ->[[MySQL]]->Create User

    Dont use mysql-root because of lazyness ;)
    Dont use mysql-root because of lazyness ;)
    (set root pw with UPDATE mysql.user SET Password=PASSWORD("new_password") WHERE User="root";) -> [[MySQL#Setting_the_initial_root_password]]



    Create a new user "fnord" with password "foobar".:
    Create a new user "fnord" with password "foobar".:
    Line 20: Line 22:
    FLUSH PRIVILEGES;
    FLUSH PRIVILEGES;
    </pre>
    </pre>

    Testscript (written in PHP):

    <?php
    /* Modification of a simple mysqlscript from php.net: http://www.php.net/mysql */

    /* Connect to DB */
    $link = mysql_connect("localhost", "fnord", "foobar")
    or die("Cannot connect to mysql: " . mysql_error());
    echo "Connected!";
    mysql_select_db("grudnuk") or die("Cannot connect to DB");

    /* Execute a sql-statement (only if you already have some data in your new db*/
    $query = "SELECT * FROM tablename";
    $result = mysql_query($query) or die("Query not successful: " . mysql_error());

    /* HTML-Output */
    echo "<table>\n";
    while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
    echo "\t<tr>\n";
    foreach ($line as $col_value) {
    echo "\t\t<td>$col_value</td>\n";
    }
    echo "\t</tr>\n";
    }
    echo "</table>\n";

    /* Free Resultset */
    mysql_free_result($result);

    /* Close Connection */
    mysql_close($link);

    ?>




    [[Category:Computer]]
    [[Category:Computer]]
    [[Category:Programs]]</pre>
    [[Category:Programs]]

    Latest revision as of 21:15, 24 October 2006

    ->MySQL->Create User

    Dont use mysql-root because of lazyness ;) (set root pw with UPDATE mysql.user SET Password=PASSWORD("new_password") WHERE User="root";) -> MySQL#Setting_the_initial_root_password

    Create a new user "fnord" with password "foobar".:

    INSERT INTO mysql.user (user, host, password)
       VALUES ('fnord', 'localhost', PASSWORD('foobar'));
    

    Create a new database "grudnuk":

    CREATE DATABASE grudnuk;
    

    Give permissions to the user "fnord" on all tables of the db "grudnuk":

    GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP
       ON grudnuk.* TO fnord;
    

    Dont forget to update permissions:

    FLUSH PRIVILEGES;
    
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.