running a sql file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

running a sql file

Post by psychotomus »

i have 2 files called mysql_schema.sql and postgres.sql. how can I execute these files??
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

i believe from the command line

using

Code: Select all

MySQL> \. /path/to/dump.sql
or using phpmyadmin for mysql, click on the sql tab, and upload your dump
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

use the mysql command

Post by dibyendrah »

use the following command :

Code: Select all

$mysql database_name < /path/to/mysql_schema.sql
Dibyendra
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

I think the question is how to execute them from a PHP script. (actually, I'd like to know too. It seems that a one statement per query rule is enforced)
sheila
Forum Commoner
Posts: 98
Joined: Mon Sep 05, 2005 9:52 pm
Location: Texas

Post by sheila »

viewtopic.php?t=46444
where $command and $arguments are what you would use on the command line

or

Read the whole sql file into a variable. Split it on ';' and send each command to the server one at a time.
You might need to do some additional work to remove comments from the sql file.
Deseree
Forum Commoner
Posts: 84
Joined: Mon Feb 13, 2006 11:35 pm

MYSQL ERROR #28

Post by Deseree »

Guys, my code was working just fine, but now it's not.... uhm... the only thing that has changed is I'm adding 3.5 million rows of data (short) into the mysql table....
MYSQL ERROR:Got error 28 from table handler
Is that too much data or why am I getting this error?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: MYSQL ERROR #28

Post by John Cartwright »

Deseree wrote:Guys, my code was working just fine, but now it's not.... uhm... the only thing that has changed is I'm adding 3.5 million rows of data (short) into the mysql table....
MYSQL ERROR:Got error 28 from table handler
Is that too much data or why am I getting this error?
Threadjacking is not cool.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

(pardon me but...) for a moment I thought you were talking about multithreading (then I checked the poster)
Post Reply