|
-
Jun 14th, 2002, 08:55 AM
#1
Thread Starter
Member
Importing a .sql file
I'm transitioning to a new host. I dumped my database into several .sql files. However I can't use phpmyadmin/Telnet/ssh yet to import them.
So what little script can I use to import the whole dealie, considering the entire file is just a bunch of SQL queries like this:
Code:
# phpMyAdmin MySQL-Dump
# version 2.2.5
# http://phpwizard.net/phpMyAdmin/
# http://phpmyadmin.sourceforge.net/ (download page)
#
# Host: localhost
# Generation Time: Jun 14, 2002 at 04:55 AM
# Server version: 3.23.48
# PHP Version: 4.0.6
# Database : `dh2255`
# --------------------------------------------------------
#
# Table structure for table `access`
#
CREATE TABLE access (
userid int(10) unsigned NOT NULL default '0',
forumid smallint(5) unsigned NOT NULL default '0',
accessmask smallint(5) unsigned NOT NULL default '0',
PRIMARY KEY (userid,forumid)
) TYPE=MyISAM;
#
# Dumping data for table `access`
#
INSERT INTO access VALUES (2, 45, 1);
INSERT INTO access VALUES (12, 45, 0);
INSERT INTO access VALUES (61, 52, 1);
INSERT INTO access VALUES (119, 76, 1);
# --------------------------------------------------------
#
# Table structure for table `adminlog`
#
CREATE TABLE adminlog (
adminlogid int(10) unsigned NOT NULL auto_increment,
userid int(10) unsigned NOT NULL default '0',
dateline int(10) unsigned NOT NULL default '0',
script varchar(20) NOT NULL default '',
action varchar(20) NOT NULL default '',
extrainfo varchar(200) NOT NULL default '',
ipaddress varchar(15) NOT NULL default '',
PRIMARY KEY (adminlogid)
) TYPE=MyISAM;
#
# Dumping data for table `adminlog`
#
INSERT INTO adminlog VALUES (1, 1, 1024023292, 'index.php', '', '', '68.54.85.254');
INSERT INTO adminlog VALUES (2, 1, 1024023294, 'options.php', '', '', '68.54.85.254');
INSERT INTO adminlog VALUES (3, 1, 1024023299, 'options.php', 'dooptions', '', '68.54.85.254');
.
.
.
-
Jun 14th, 2002, 09:11 AM
#2
Fanatic Member
well you could make all of them valid php code and then run it as a script, or wait till you can use telnet, ssh, or phpMyAdmin.
-
Jun 14th, 2002, 09:27 AM
#3
Thread Starter
Member
With all this work I think I'll just wait for SSH to be activated. 
When it is, what do I do? mysqlimport dbname dbfile.sql?
-
Jun 14th, 2002, 09:29 AM
#4
Fanatic Member
sorry I never have really used ssh or telnet for that type of thing. I really should but too little time to learn it.
Maybe scoutt will know.
-
Jun 14th, 2002, 10:59 AM
#5
why do it the hard way. save the database in one big sql file and then use phpMyAdmin to load it all back in, why telnet?
you still have to have the database created so you can get the name then it should run no problem.
sorry I don't use telnet as most ISP disable it for security reasons.
-
Jun 14th, 2002, 12:33 PM
#6
Thread Starter
Member
Originally posted by scoutt
why do it the hard way. save the database in one big sql file and then use phpMyAdmin to load it all back in, why telnet?
you still have to have the database created so you can get the name then it should run no problem.
sorry I don't use telnet as most ISP disable it for security reasons.
My old host doesn't have SSH/Telnet so I can't backup the whole thing at once. The problem is that the DB dump has a PHP operation timed out error which is obvious why it happens. Only the new host has SSH.
BTW I did mean SSH, not Telnet for the new host
-
Jun 14th, 2002, 12:36 PM
#7
Fanatic Member
You said it timed out. Were you dumping it one table at a time or trying to dump the who database from phpMyAdmin?
I personally suggest clicking on the table name and dumping each individual table.
-Matt
-
Jun 14th, 2002, 12:50 PM
#8
even if you did it table by table you can still use phpMyAdmin.
-
Jun 14th, 2002, 12:54 PM
#9
Thread Starter
Member
There are tons of tables (55 or so). I did it like this:
Attachments
Posts
Everything else
No worries though, I was finally able to import everything via SSH.
-
Jun 14th, 2002, 12:58 PM
#10
cool, but in the future you can get the table structor by itself then you can get the data in however many files it takes then you can load all the tables at once, then piece in the data. but if you prefer the SSH way then cool. FYI
-
Jun 14th, 2002, 02:23 PM
#11
PowerPoster
*ignorant* what the hell is ssh?
-
Jun 14th, 2002, 02:24 PM
#12
Fanatic Member
-
Jun 14th, 2002, 02:33 PM
#13
PowerPoster
-
Jun 14th, 2002, 02:48 PM
#14
Thread Starter
Member
Originally posted by chrisjk
*ignorant* what the hell is ssh?
Teh 1337 n0n-n00b unh4x0rable version of Telnet
-
Jun 14th, 2002, 02:53 PM
#15
PowerPoster
all this talk of telnet and I just noticed my host now gives me telnet and SSH access
-
Jul 1st, 2002, 08:55 PM
#16
Thread Starter
Member
Originally posted by scoutt
cool, but in the future you can get the table structor by itself then you can get the data in however many files it takes then you can load all the tables at once, then piece in the data. but if you prefer the SSH way then cool. FYI
The problem with that is that the structure probably only makes up a tiny sliver of the MySQL db size, the vast majority was in the actual data (attachments and posts).
But all is well in the land of SSH.
-
Jul 1st, 2002, 09:22 PM
#17
Junior Member
it would be possible to make a php script to do it for you... something like this:
PHP Code:
<?
$connect = mysql_connect("host", "user", "pass");
mysql_select_db("db", $connect);
// Open the sql file so it can be read and processed...
$sql_file = fopen("file.sql", "r"); // Read Only..
$query = fread($sql_file, filesize($sql_file); //Read the whole file into a variable
fclose($sql_file);
if(mysql_query($query, $connect)
{
echo "SQL File Finished Successfully!";
}
else
{
echo "Something Happened that wasen't good!";
}
?>
No guarantee the syntax is perfect... working off of mind..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|