Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
-
hanzo
- Forum Newbie
- Posts: 16
- Joined: Thu Nov 17, 2005 10:14 am
Post
by hanzo »
Hello,
I know you can create a Mysql database with PHP this way:
Code: Select all
$query = "CREATE DATABASE phpcake";
$result = mysql_query($query);
But how do I know what the username and password for the database are or how can I set those data?
Thanks
-
Jenk
- DevNet Master
- Posts: 3587
- Joined: Mon Sep 19, 2005 6:24 am
- Location: London
Post
by Jenk »
in exactly the same way..
Code: Select all
<?php
$sql = "SET PASSWORD FOR 'user'@'domain' = OLD PASSWORD('new pass')";
mysql_query($sql) or die(mysql_error());
?>
-
timvw
- DevNet Master
- Posts: 4897
- Joined: Mon Jan 19, 2004 11:11 pm
- Location: Leuven, Belgium
Post
by timvw »
I don't like the oldpassword
Code: Select all
grant all on databasename.* to 'user'@'localhost' identified by 'hispassword';
-
Jenk
- DevNet Master
- Posts: 3587
- Joined: Mon Sep 19, 2005 6:24 am
- Location: London
Post
by Jenk »
PHP does though
re: "Client protocol blah blah error"
-
timvw
- DevNet Master
- Posts: 4897
- Joined: Mon Jan 19, 2004 11:11 pm
- Location: Leuven, Belgium
Post
by timvw »
time to teach it some manners..

-
hanzo
- Forum Newbie
- Posts: 16
- Joined: Thu Nov 17, 2005 10:14 am
Post
by hanzo »
timvw wrote:I don't like the oldpassword
Code: Select all
grant all on databasename.* to 'user'@'localhost' identified by 'hispassword';
do I have to create a new user first or can it be a new one in the code?
-
Gambler
- Forum Contributor
- Posts: 246
- Joined: Thu Dec 08, 2005 7:10 pm
Post
by Gambler »
granting creates users by itself.
-
hanzo
- Forum Newbie
- Posts: 16
- Joined: Thu Nov 17, 2005 10:14 am
Post
by hanzo »
thanks

-
hanzo
- Forum Newbie
- Posts: 16
- Joined: Thu Nov 17, 2005 10:14 am
Post
by hanzo »
When I try to create a database I get this
Access denied for user 'hanzo_databases'@'localhost' to database 'hanzo_mydgd'
The login I'm using works well for other queries.
-
Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Post
by Chris Corbyn »
You don't have permission to create databases then.... is this shared hosting?
It's a pain but if you're limited to one or two databases, using prefixes on your table names can be a clean(ish) separation.
-
hanzo
- Forum Newbie
- Posts: 16
- Joined: Thu Nov 17, 2005 10:14 am
Post
by hanzo »
It's reseller hosting with a directadmin control panel
I've got unlimited databases. Shall I contact the admin about it?