
|
View Full Version : Helpful MySQL Database Setup Script
brandonk 06-06-2001, 06:20 PM Hi there!
I have succesfully completed my first PHP script! (and its not much)
When a client emails me and asks for a mysql database setup (and a username and password to use it) I've usually had to login via shell and set it up... But not anymore!
All you do is go to the PHP script, type in the desired database name, username, and password, and the clients email address. The script will set it up instantly and send out a nice little email telling the client it has been setup (it also tells them the db name, username and password).
You just have to edit a couple lines (that I've conveniently placed at the top of the script) and your set to go!
You can download the script at:
http://www.raqzone.com/mysqlsetup.zip
Install instructions are included, even though it's quite simple.
If you have any other ideas on making us web hosters lives a bit easier, let me know!
Dude where have you been? We've been using a script that was custom built (for only $10 dollars!) that it creates, modifies and deletes MySQL databases. It also reloads MySQL..
But congrats on creating your first php script! Maybe I should start to learn php.
Oh ya and I'm using autosetup (1.2) from www.northwesthost.com/scripts
It was worth the $50 dollars (now it costs $90). Check it out.
Chicken 06-06-2001, 07:32 PM Brandon, that's very generous of you to sahre the script and info. Thank you. Also, you've been very helpful with other things (around here, and via email with me), and I just wanted to say thanks!
brandonk 06-07-2001, 11:47 AM Originally posted by Dim8
Dude where have you been? We've been using a script that was custom built (for only $10 dollars!) that it creates, modifies and deletes MySQL databases. It also reloads MySQL..
Where have I been? Umm... not sure how to answer that one.
Anyways, I've already got an automatic setup system that I had custom Built (which looks a hell of a lot better than that thing). So I'm slowly adding on to what I've got, and I just figured I'd release it...
Hey Chicken - I love your new host chatroom! That's awesome!
Omair Haroon 06-11-2001, 01:29 PM well. sorry to say brandon, this script is not working at all.
I tried it twice on two systems but no result.
Anything you may have to say.. :(
Thanks,
broken 06-11-2001, 04:25 PM Installed and worked beautifully here. Thanks for sharing Brandon.
Omair did you follow the install instructions?
Omair Haroon 06-11-2001, 04:30 PM I changed the password and changed the email addy. and did nothing else.
is there anything else that should be done ?
Thanks,
Omair Haroon 06-11-2001, 04:32 PM is it necessary that we set the .htaccess file through telnet ?
can't we simply upload those two files ?
Thanks,
broken 06-11-2001, 04:39 PM I don't see why not, I would think it'd be much more fun to do through telnet though. :D
I just stuck the mysql.php in a previously secured directory with some other apps of this flavor, pico'd in the changes and ran it...works beautifully.
Omair Haroon 06-11-2001, 05:10 PM may brandon could help me.
Thanks,
Is the script running perfectly well on a Raq3? I am very interested in getting the script but I don't want troubles. :blush: hehe... I am not really an elite admin who is able to fix everything. :D
Omair Haroon 06-12-2001, 05:53 AM well the script is not running here.
may be brandon can say something.
thanks,
i have a script that does the exact same stuff (add a db, remove, backup, change the password, reload MySQL) but I paid for it but it's for sell for like $15 dollars. e-mail me for more info. it doesn't email the user and tell them that their MySQL DB has been setup.. but anyone is more than welcomed to add that feature. =)
[?] Whoever is having problems with the script, please tell us what error message (if any) you are recieving, maybe someone else can help ya to fix it! Since it is a php script, most php scripts are fairly easy to fix. =)
Omair Haroon 06-12-2001, 06:13 AM well.
what is do is simply emails the user that the database have been setup but the database have'nt been actually setup.
any idea what would be the problem ?
Thanks,
Crazy 06-15-2001, 05:41 PM Work great for me, i am on a raq4i...
great script btw!, any chance of adding user permissions to it also?....
hoster 06-15-2001, 08:54 PM I just downloaded it and it works great running a Raq4r.
Great job
Rich:D
What security measures are in the script besides protecting it via .htaccess.
Do you check referrer fields?
Require passwords?
I assume that the script has access to MySQL as root, which can really be problematic if it is not well secured. We've used similar scripts, but found many of them lacked appropriate security. Just curious as to what security your script offers.....
Thanks for the contribution .... (I'm just paranoid about security, that's all).
brandonk 06-18-2001, 12:43 PM Originally posted by Omair Haroon
well.
what is do is simply emails the user that the database have been setup but the database have'nt been actually setup.
any idea what would be the problem ?
Thanks,
Hi Guys,
I've been on vacation for the past week (err no response). What is the error?
AbbasJaffarali 06-18-2001, 01:32 PM Has anybody used PHPMyAdmin?
Does it do a similar kind of thing?
Thanks
Abbas
brandonk 06-18-2001, 02:10 PM Abbas,
This is just a little script for a hosting company.. It makes setting up a database for a client very easy!
Omair Haroon 06-18-2001, 02:20 PM hey brandon,
the script is not working on my raq3..
can you tell me what woould be problem in your idea ?
Thanks,
You might want to try hotscripts.com. They have numerous PHP and PERL scripts for dealing with databases.
brandonk 06-18-2001, 06:25 PM Originally posted by Omair Haroon
hey brandon,
the script is not working on my raq3..
can you tell me what woould be problem in your idea ?
Thanks,
Omair,
What isn't working? Are you receiving an error message? Do you have PHP installed? If you can give me some details I might be able to help, and others might as well. This script should work on ANY server that has MySQL and PHP.
afriq 06-19-2001, 01:47 AM Originally posted by AbbasJaffarali
Has anybody used PHPMyAdmin?
Does it do a similar kind of thing?
PHPMyAdmin is a GUI interface that allows one to do almost anything with your mySQL database, such as creation of new tables, inserts, updates and selects from tables, browsing of data, exporting of data, etc.
All of the above obviously depends on the permissions assigned to the user.
The beauty of PHPMyAdmin is that you don't have to provide telnet/SSH access to your clients - they can manage their database via a browser.
But why don't you check out their site at
http://phpwizard.net/projects/phpMyAdmin/ ? (http://phpwizard.net/projects/phpMyAdmin/)
Omair Haroon 06-19-2001, 02:47 AM brandon,
I have PHP 4.01 and mySQL installed properly because I am also running PHPWeb Support which ofcourse run with mySQL and PHP.
I am not receiving any errors. But when I add a database, username and password. It simply gives emails me the mail sayign account created etc.
but no accounts are created.
Anyidea whats going on ?
Thanks,
Omair Haroon
Emm... Does this script runs well on other platform such as Redhat or FreeBSD? Or it's just designed to run under RaQ ?
eriky 06-22-2001, 06:25 PM Donovan, it should work on any server with php and MySQL (this was said a few posts ago too).
And you have to use a root account to create new users of course..
Chris 06-22-2001, 11:57 PM Nice script, worked perfect....
Oops... I didn't saw that until just now. Sorry :blush:
captnroger 06-26-2001, 04:13 PM I'm getting an internal server error trying to install this on a Raq4i.
I installed in a directory, went to that directory, created this .htaccess file as described (path is correct), set the password, tried to pull it up, and I'm getting the infamous Internal Server Error.
PHP4 is installed and working well...any ideas?
brandonk 06-26-2001, 07:49 PM Originally posted by captnroger
I'm getting an internal server error trying to install this on a Raq4i.
I installed in a directory, went to that directory, created this .htaccess file as described (path is correct), set the password, tried to pull it up, and I'm getting the infamous Internal Server Error.
PHP4 is installed and working well...any ideas?
Captnroger,
This infamous error has nothing to do with the script, it's htaccess and how it's setup on a RaQ4. I was searching through the cobalt users list archive and I found the solution, it has to do with a tweak that a cobalt tech performed on the access.conf. I just tried pulling the page for you, but right now the search utility isn't working on the archives... I'll try again and I"ll post the fix here.
ThePrimeHost 08-26-2001, 11:13 PM I receive the following errors when I test the script:
Warning: MySQL Connection Failed: Access denied for user: 'root@localhost' (Using password: YES) in /home/sites/home/web/mysql.php on line 35
Warning: Supplied argument is not a valid MySQL-Link resource in /home/sites/home/web/mysql.php on line 37
Warning: Supplied argument is not a valid MySQL-Link resource in /home/sites/home/web/mysql.php on line 40
Warning: Supplied argument is not a valid MySQL-Link resource in /home/sites/home/web/mysql.php on line 45
Warning: Supplied argument is not a valid MySQL-Link resource in /home/sites/home/web/mysql.php on line 47
Any ideas? I followed your instructions word for word...the only question that I had was the following:
3) Login to telnet, go to where the mysql.php file is located,
type "pico .htaccess", and then replace the path after "AuthUserFile",
then copy and paste into the .htaccess file:
Replace it with what? How do I save and go back to the pevious screen? Ijust logged out and logged back in to create the htaccess file.
Regards,
Darrell Buckhaults
madsere 08-27-2001, 07:53 AM Darrell,
Seems to me you forgot to change the $mypw variable. That needs to be set to the "root" password of MySQL -not the systeme ("the telnet").
Brandon,
Just a suggestion: Intead of:
mysql_query("insert into user (Host,User,Password) VALUES
('localhost','$formuser',PASSWORD('$formpass'));",$db);
mysql_query("insert into db
values('localhost','$formdb','$formuser','Y','Y','Y','Y','Y','Y','N','Y','Y','Y');");
I would suggest using:
mysql_query("grant all on $formdb.* to $formuser@localhost identified by $formpass");
This is just one command that does the whole you have in two commands above the "proper" (imo anyway) way
Rgds,
Rene
ThePrimeHost 08-28-2001, 08:27 PM I updated my password via telnet and added it to the script. I now get this error:
Warning: MySQL Connection Failed: Access denied for user: 'root@localhost' (Using password: YES) in /home/sites/site3/web/mysql.php on line 35
Warning: Supplied argument is not a valid MySQL-Link resource in /home/sites/site3/web/mysql.php on line 37
Warning: Supplied argument is not a valid MySQL-Link resource in /home/sites/site3/web/mysql.php on line 40
Warning: Supplied argument is not a valid MySQL-Link resource in /home/sites/site3/web/mysql.php on line 45
Warning: Supplied argument is not a valid MySQL-Link resource in /home/sites/site3/web/mysql.php on line 47
Suggestions?
ThePrimeHost 08-28-2001, 08:48 PM I updated my password via telnet and added it to the script. I now get this error:
Warning: MySQL Connection Failed: Access denied for user: 'root@localhost' (Using password: YES) in /home/sites/site3/web/mysql.php on line 35
Warning: Supplied argument is not a valid MySQL-Link resource in /home/sites/site3/web/mysql.php on line 37
Warning: Supplied argument is not a valid MySQL-Link resource in /home/sites/site3/web/mysql.php on line 40
Warning: Supplied argument is not a valid MySQL-Link resource in /home/sites/site3/web/mysql.php on line 45
Warning: Supplied argument is not a valid MySQL-Link resource in /home/sites/site3/web/mysql.php on line 47
Suggestions?
dutchie 09-19-2001, 07:01 AM Brandonk,
I get a server error also, but the .htacces file i've put in my cgi-bin works as it should.
Maybe i made a error with creating the .htacces file in the script directory.
It wasn't clear to me if the authuserfile path has to point to the php script or the mysql directory on my server.
If it has to point to the mysql directory, can you tell me where it is ? i find a mysql in /home with a subdirectory /mysql should it point to that subdirectory ?
Thank you in advance !
Works great :-)
Installed it on a RaQ4i.
Thx for sharing :D:beer:
:scatter:
Haisoft 10-29-2001, 04:49 PM It's quite simple what is not working ! You have got to give the script your mysql root username and password otherwise it can't create a database !
|