Page 1 of 1
install script
Posted: Mon Feb 07, 2005 5:27 pm
by shiznatix
i wanna write a script that automatically creates a database, creates the tables, and creates the fields. i have all the sql laid. how do i do this?
Posted: Mon Feb 07, 2005 5:33 pm
by John Cartwright
Code: Select all
$sql = "CREATE ..... all your sql goes here";
mysql_connect('localhost','user','pass')
mysql_query($sql) or die(mysql_error());
.......
I also recommend you have either as install.php or /install/
and then check to make sure the install file/folder is gone when your site goes live
so in index.php
Code: Select all
if (is_file('install.php'))
exit('Please delete install.php');
This is so people won't be able to re-install your database.
also might want to chck
http://dev.mysql.com/doc/mysql/en/index.html
Posted: Mon Feb 07, 2005 5:49 pm
by feyd
multiple queries aren't allowed on older versions of MySQL through a single query call.
The only way I know how, outside of command line, is to load the entire file, strip the comments, break apart the commands, and execute each in sequence.
Posted: Mon Feb 07, 2005 7:09 pm
by shiznatix
ok im trying to create the database, i have the username and pass and all that but it dies with the error
"Access denied for user: 'wesmok2_natix@localhost' to database 'wesmok2_forum'"
and yes the username and password are correct. whats up with this?
Posted: Mon Feb 07, 2005 7:12 pm
by feyd
the user doesn't have access rights to that database.
Posted: Mon Feb 07, 2005 7:20 pm
by shiznatix
the database hasnt been created yet...thats what im trying to do
Code: Select all
$sql = "CREATE DATABASE `forum`;";
mysql_connect('localhost', $dbusername, $dbpassword);
mysql_query($sql) or die(mysql_error());
is giving me that error
Posted: Mon Feb 07, 2005 7:30 pm
by feyd
does the user you are running this from have rights to create a database? I'd bet no.