SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    446
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    backup selected tables in mysql db to a sql file

    I found this snippet on stackoverflow:
    Code:
    mysqldump db_name table_name > table_name.sql
    How do I write it into a mysql query if I wanted to save the output to e:\sql\alpha.sql?

    I made this attempt, but no go:

    Code:
    mysql_query("mysqldump emily alpha > e:\sql\alpha.sql") or die(mysql_error());

  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    446
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Obviously, I need to use shell_exec().

    This code produces empty output (my db doesn't have a pw).
    Code:
    shell_exec("mysqldump armor '' emily alpha > e:/sql/alpha2.sql");
    Why?

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    446
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    OK.

    This works from the command line:
    Code:
    e:\wamp\bin\mysql\mysql5.1.33\bin\mysqldump -h localhost -u armor -p  emily alpha> e:\sql\alpha4.sql
    How do I run this from php without being promped for a pw? I thought I could use shell_exec(), but no joy.

  4. #4
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    446
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Solved.
    Code:
    shell_exec("\wamp\bin\mysql\mysql5.1.33\bin\mysqldump -h localhost -u armor emily alpha> e:\sql\alpha5.sql");
    Was missing the path for mysqldump.


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
  •