Import mysql dump using php

后端 未结 4 940
北荒
北荒 2021-02-10 14:06

I have mysql dump file. How I can import this file into mysql using php?

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-10 14:38

    You dump is probably a file that just contains a lot of SQL queries.

    The simplest way to import such a dump is to use the mysql command-line client (especially if the file is big !) :

    mysql --user=USERNAME --password=PASSWORD --host=HOST DB_NAME < /path/to/your/file.sql
    


    If you can connect to your server with some command-line access (typically, using ssh), that's the way to go.

    Else, I suppose you could execute such a command with system()

提交回复
热议问题