corsasport.co.uk
 

Corsa Sport » Message Board » Off Day » Geek Day » SQL / Database Boffins


New Topic

New Poll
  Subscribe | Add to Favourites

You are not logged in and may not post or reply to messages. Please log in or create a new account or mail us about fixing an existing one - register@corsasport.co.uk

There are also many more features available when you are logged in such as private messages, buddy list, location services, post search and more.


Author SQL / Database Boffins
Bart
Member

Registered: 19th Aug 02
Location: Midsomer Norton, Bristol Avon
User status: Offline
2nd Apr 09 at 10:29   View User's Profile U2U Member Reply With Quote

I have a questions regarding SQL tables etc.
I have a forum in <location1> and would like to back it up and import it to <location2>, from one server/host to another.

I’ve installed the basic forum software on host2 and I was simply hoping to backup/restore between the two. The only downside is, host1 has a table prefix of phpbb_ for each table, where as the installation for host1 was a one click installation using the host, and it does not have the prefix.

Is there any easy way to resolve this? Or is it likely to get very messy? I have no real experience with SQL/tables.
willay
Moderator
Organiser: South East, National Events
Premium Member


Avatar

Registered: 10th Nov 02
Location: Roydon, Essex
User status: Offline
2nd Apr 09 at 12:03   View Garage View User's Profile U2U Member Reply With Quote

mysql?

If so then use mysqldump

> mysqldump
Usage: mysqldump [OPTIONS] database [tables]
OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
OR mysqldump [OPTIONS] --all-databases [OPTIONS]
For more options, use mysqldump --help
>

so just do a

> mysqldump --database dbnamehere > my_databases.sql

Tehn when you want to put that data into a different database...

> mysql dbnamehere < my_databases.sql

sorted.


[Edited on 02-04-2009 by willay]
Sam
Moderator
Premium Member


Registered: 24th Dec 99
Location: West Midlands
User status: Offline
2nd Apr 09 at 12:58   View User's Profile U2U Member Reply With Quote

Or phpMyAdmin, export the database from the old host and import it into the new database.

Most hosts give you phpMyAdmin access, more user friendly/easier than hardcore SSH command-line stuff like what William has described.

[Edited on 02-04-2009 by Sam]
Bart
Member

Registered: 19th Aug 02
Location: Midsomer Norton, Bristol Avon
User status: Offline
2nd Apr 09 at 13:20   View User's Profile U2U Member Reply With Quote

Yes, sorry guys, its phpMyAdmin.

Does that mean I will have to manually edit each table name and remove the prefix myself?
Its not the end of the world... just going to take some time.

I was also wondering, if I modified the tables, what will that conflict with when writing (i.e the php files?).
There must be something at file/folder level to tell the website which table it should be writing to, or is this likely to be within a config file?

Thanks guys.

[Edited on 02-04-2009 by Bart]
Ian
Site Administrator

Avatar

Registered: 28th Aug 99
Location: Liverpool
User status: Offline
2nd Apr 09 at 18:34   View Garage View User's Profile U2U Member Reply With Quote

Table prefix is normally in the config so you may be able to add your prefix to the config on the new install and it'll just work.

Failing that you'll have the raw SQL commands if you use mysqldump or export from phpMyAdmin so you can fairly easily use a text editor to find/replace the strings.

It won't conflict so far as the PHP is concerned, in fact it'll never know. It just prepends the table prefix from the config and goes and does queries on that table. If the table is there and the privs are right it'll work.
willay
Moderator
Organiser: South East, National Events
Premium Member


Avatar

Registered: 10th Nov 02
Location: Roydon, Essex
User status: Offline
3rd Apr 09 at 04:04   View Garage View User's Profile U2U Member Reply With Quote

quote:
Originally posted by Samthan hardcore SSH command-line stuff like what William has described.


fags!!!
ENB
Member

Registered: 24th Apr 06
User status: Offline
3rd Apr 09 at 12:09   View User's Profile U2U Member Reply With Quote

quote:
Originally posted by Sam
Or phpMyAdmin, export the database from the old host and import it into the new database.

Most hosts give you phpMyAdmin access, more user friendly/easier than hardcore SSH command-line stuff like what William has described.

[Edited on 02-04-2009 by Sam]


But by using a bash script you can automate the backup and restore.
Bart
Member

Registered: 19th Aug 02
Location: Midsomer Norton, Bristol Avon
User status: Offline
3rd Apr 09 at 14:14   View User's Profile U2U Member Reply With Quote

Ian, I can backup as a .sql file and simply use notepad2 to do a nice find/replace, (ive just opened another SQL file and all the text appears readable), so im ok with that bit.

With regard to the "config", are you referring to a likely config.php file or something within the database itself?
PaulW
Member

Registered: 26th Jan 03
Location: Atherton, Greater Manchester
User status: Offline
3rd Apr 09 at 14:47   View User's Profile U2U Member Reply With Quote

quote:
Originally posted by Sam
than hardcore SSH command-line stuff like what William has described.


Its far better to do backups/imports via SSH anyways, especially on large databases. Although I just have a bash script to do automated backups at set intervals

Plus, with phpMyAdmin, you still have timeout issues or file size upload restrictions depending on how php is configured (aswell as whatever http server program you are using)
Ian
Site Administrator

Avatar

Registered: 28th Aug 99
Location: Liverpool
User status: Offline
5th Apr 09 at 00:46   View Garage View User's Profile U2U Member Reply With Quote

quote:
Originally posted by Bart
With regard to the "config", are you referring to a likely config.php file or something within the database itself?
Yeah config.php in the forum dir, just get in there and have a look for $table_prefix

Ditto the commends on SSH being less risky.
Bart
Member

Registered: 19th Aug 02
Location: Midsomer Norton, Bristol Avon
User status: Offline
5th Apr 09 at 15:30   View User's Profile U2U Member Reply With Quote

well, I manually edited the .sql backup and removed the pre-fix using find/replace.

But afterwards I did notice that prefix setting in the config. Either way, job done

thanks guys

 
New Topic

New Poll

  Related Threads Author Forum Replies Views Last Post
website help :( Drew Geek Day 18 1106
30th Nov 04 at 21:26
by Drew
 
Webspace A1EX Geek Day 7 1047
25th Mar 06 at 16:03
by MikeLamb
 
SQL Server MarkW Geek Day 18 892
2nd Feb 07 at 20:38
by MarkW
 
FAO: Programmers barteh Geek Day 6 824
6th Nov 07 at 14:02
by barteh
 
SQL Connection String Jodi_the_g Geek Day 1 198
11th Sep 08 at 13:23
by James
 

Corsa Sport » Message Board » Off Day » Geek Day » SQL / Database Boffins 29 database queries in 0.0226760 seconds