Database Dump with PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Noodle

    Database Dump with PHP

    Hi,

    I want to dump out a database to the screen using mysqldump, like so...

    <?php
    echo system('mysqldu mp -h localhost -u user -p password
    my_database');
    ?>

    However, it won't accept my password being passed in like this. Is this
    a mysql configuration problem?

    Normally, if I were to do this in a terminal window, I would type:
    'mysqldump -u user -p my_database', it would then prompt me for my
    password before performing the operation.

    Any suggestions on how this can be done?

    TIA.

    Noodle

  • Mateusz Markowski

    #2
    Re: Database Dump with PHP


    Noodle napisal(a):
    Hi,
    >
    I want to dump out a database to the screen using mysqldump, like so...
    >
    <?php
    echo system('mysqldu mp -h localhost -u user -p password
    my_database');
    ?>
    >
    However, it won't accept my password being passed in like this. Is this
    a mysql configuration problem?
    No, just take a look at mysqldump manpage. There is no option for
    password, beucause of security reasons. If it was possible, everyone
    would see your password by typing just: $ps -aux.

    Maybe try to open pipe to mysqldump proccess and then put password into
    it. (php.net/popen)

    Comment

    • Michael

      #3
      Re: Database Dump with PHP

      "There is no option for password, beucause of security reasons"
      Wrong, I have an automated backup script (powered by PHP) and it uses
      the mysqldump terminal command and you can specify password (because I
      do). The poster above you was correct (the poster called NC).
      Mateusz Markowski wrote:
      Noodle napisal(a):
      Hi,

      I want to dump out a database to the screen using mysqldump, like so...

      <?php
      echo system('mysqldu mp -h localhost -u user -p password
      my_database');
      ?>

      However, it won't accept my password being passed in like this. Is this
      a mysql configuration problem?
      >
      No, just take a look at mysqldump manpage. There is no option for
      password, beucause of security reasons. If it was possible, everyone
      would see your password by typing just: $ps -aux.
      >
      Maybe try to open pipe to mysqldump proccess and then put password into
      it. (php.net/popen)

      Comment

      • Noodle

        #4
        Re: Database Dump with PHP


        NC wrote:
        Noodle wrote:

        I want to dump out a database to the screen using
        mysqldump, like so...

        <?php
        echo system('mysqldu mp -h localhost -u user
        -p password my_database');
        ?>

        However, it won't accept my password being passed
        in like this. Is this a mysql configuration problem?
        >
        No, it's your not having read the MySQL Manual. When you enter
        password on the command line, there should not be any whitespace
        between -p and password:
        >
        mysqldump -h localhost -u user -ppassword my_database
        >
        Cheers,
        NC
        Thanks NC, this has fixed the password problem.

        Comment

        Working...