< MySQL
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]] |
[[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;