How to export some rows of a mysql table with where clause from a php script?

后端 未结 4 1023
无人共我
无人共我 2021-01-04 08:45

I have a mysql table say test and I want to create a importable .sql file for rows where id is between 10 and 100 using php script.

I want to create a sql file say t

4条回答
  •  迷失自我
    2021-01-04 08:57

    As mentioned in the comments you can use mysqldump the following way.

    mysqldump --user=... --password=... --host=... DB_NAME --where= > /path/to/output/file.sql
    

    If you want this to be in your php file you can do the following

    exec('mysqldump --user=... --password=... --host=... DB_NAME --where= > /path/to/output/file.sql');
    

提交回复
热议问题