How to convert .sql file to tables in mysql db

前端 未结 3 1204
庸人自扰
庸人自扰 2021-01-25 14:40

I have .sql files that I\'m guessing is auto-generated. I did not generate this file, but anyway it includes the database name and all tables with fields. I\'d like to add the d

3条回答
  •  北荒
    北荒 (楼主)
    2021-01-25 14:58

    From command-line:

     mysql -u root -p databaseName < file.sql
    

    Where databaseName is an already created empty database and file.sql is the .sql file you have, you must be in the same folder as the file when you run the command. This also assumes using root as the user and that it is password protected. Modify as needed for your own setup.

    Additionally, you can do the reverse by flipping the angled bracket to create a database dump to a file. Like below.

     mysql -u root -p databaseName > file.sql
    

提交回复
热议问题