SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: MySql Question

  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2000
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Let's say that I wanted to import a table from another server. The table is named stories. How would I go about doing it either in phpmyadmin or SSH?
    Thanks for the help in advance.
    Steven
    Have you ever been ripped off, lied to or cheated? If so, check out
    Baddealings.com

  2. #2
    SitePoint Addict isuru's Avatar
    Join Date
    Nov 2000
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Im not an expert in this subject but couldn't you just get a mysqldump of your old database and then create a new database on the new server and then use the msqldumped file in phpmyadmin to recreate the database?

  3. #3
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Once you mysqldump into a file named, for example, 'stories.sql,' do this:

    mail -s SQLDump you@domain.tld < stories.sql

    Then check your email and that is is. Paste that into your ssh connection or phpMyAdmin window.

    OR...
    mysqldump into http://domain.tld/stories.sql and do:
    lynx -source "http://domain.tld/stories.sql" > stories.sql
    mysql -u yourusername -p < stories.sql
    Hope this helps...

    p.s. to be a REAL wizard, you can do:
    lynx -source "http://domain.tld/stories.sql" | mysql -u yourusername -p
    <Edited by qslack on 01-23-2001 at 08:58 PM>

  4. #4
    SitePoint Enthusiast
    Join Date
    Sep 2000
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Isiru-
    Thanks for the reply, and I know that your suggestion is possible. Here is what I want to do. I run a forum on my site as well as phpnuke. Now there was a hack a short time ago integrating the two. I have made the integration tonight, and I want to import my stories table, because that is where a large part of the content of my site. You see here is what I have
    216.234.165.58/forums/index.php
    and it should be filled with stories like
    http://www.baddealings.com

    So how can I do a dump of 1 table?

    Thanks
    Steven
    <Edited by steven on 01-23-2001 at 10:04 PM>
    Have you ever been ripped off, lied to or cheated? If so, check out
    Baddealings.com

  5. #5
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    So how can I do a dump of 1 table?
    Here's the command you need:

    mysqldump -uuser -ppassword --add-drop-table db_name table_name > table_name.sql

    Substitute the appropriate values for the bold items. The --add-drop-table option tells MySQL to delete and recreate the table if it already exists when restoring the dump.

    Once you've moved the table_name.sql file to your new server, you can restore it with the following command:

    mysql -uuser -ppassword db_name < table_name.sql
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  6. #6
    SitePoint Enthusiast
    Join Date
    Sep 2000
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you guys very much for all your help as I used kyank's method and it worked perfectly in a matter of seconds. Hopefully one day I'll be answering the questions of some newbie making his day.
    Have you ever been ripped off, lied to or cheated? If so, check out
    Baddealings.com


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •