[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cobalt-users] MySql database setup (help out my Cobalt hoster)
- Subject: Re: [cobalt-users] MySql database setup (help out my Cobalt hoster)
- From: "Charles Williams \(CEO\)" <hosting.mailing.list.account@xxxxxxxxxxxxxxx>
- Date: Thu May 31 18:22:35 2001
- List-id: Mailing list for users to share thoughts on Cobalt products. <cobalt-users.list.cobalt.com>
----- Original Message -----
From: "Cubicware admin" <cubicware@xxxxxxxxxxxxx>
To: <cobalt-users@xxxxxxxxxxxxxxx>
Sent: Friday, May 25, 2001 3:30 PM
Subject: [cobalt-users] MySql database setup (help out my Cobalt hoster)
> I've purchased several domains from a Cobalt hosing user. So far so good.
> I've asked him to add some MySql databases for me - but unfortunately
either
> he doesn't quite know how to do it or I dont quite know what to ask him.
> Perhaps if it wouldn't be to much trouble would someone mind posting the
> mysql commands that he will need to run in order to set up a database on
his
> server that I will be able to then login to and create tables and data and
> so on from localhost and remotely (web app)? I understand what I need to
do
> once I have access, but I am not sure how to do the server side setup. On
> another hosting company I use, I just asked for a database and they gave
me
> a userid and password and I was all set.
>
> John
John,
Below is a quick and dirty PHP script to setup a database on a server with
access provided to the user given and password given.
BEWARE! I said quick and dirty and I meant quick and dirty. There are NO
CHECKS DONE! So make sure they know what they are doing before they use
this. I do not accept any responsibility for it's use and/or mis-use, and
all the other disclaimer jazz.
chuck
<?
$myname = 'mysql_root_user';
$mypass = 'mysql_root_user_password';
if (isset($db_name) && isset($user_name) && isset($pass_word)){
$link = mysql_pconnect($server_name, $myname, $mypass) or die ("Could
not connect to MySQL Server");
if (mysql_create_db($db_name, $link)){
print ("Database created successfully \n");
} else {
printf ("Error creating database: %s \n ", mysql_error ());
echo"<p>";
};
mysql_select_db('mysql', $link) or die ("Could not access the -mysql-
database \n ");
mysql_query("insert into user (Host, User, Password, Select_priv,
Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, Reload_priv,
Shutdown_priv, Process_priv, File_priv, Grant_priv, References_priv,
Index_priv, Alter_priv)
VALUES ('$server_name', '$user_name', PASSWORD('".$pass_word."'), 'N', 'N',
'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N')",
$link) or die ("<b>Username is already present! <a href'mysqlusers.php3'>
Please go back and try again..</a></b>");
echo "<br>";
mysql_query("INSERT INTO db (Host, Db, User, Select_priv, Insert_priv,
Update_priv, Delete_priv, Create_priv, Drop_priv, Grant_priv,
References_priv, Index_priv, Alter_priv)
VALUES ('$server_name', '$db_name', '$user_name', 'Y', 'Y', 'Y', 'Y', 'Y',
'Y', '', '', '', '')", $link)
or die ("Error adding info to db table");
mysql_query("flush privileges");
echo"<p><a href='mysqlusers.php3'><b>Click Here to add another
user...</b></a>";
}else{ echo'<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
<title>Title here!</title>
</head>
<body>
<form action="mysqlusers.php3" method="post">
<b>Server Name:</b> <input type="text" name="server_name" size="40"
maxlength="80" value="server1.acnsnet.com"><p>
<b>Database Name:</b> <input type="text" name="db_name" size="40"
maxlength="80" value=""><p>
<b>Username:</b> <input type="text" name="user_name" size="40"
maxlength="80" value=""><p>
<b>Password:</b> <input type="text" name="pass_word" size="40"
maxlength="80" value=""><p>
<input type="submit" value="GO"> <input type="reset"
value="nope">
</form>
</body>
</html>';
}
?>