How to convert .sql file to tables in mysql db

前端 未结 3 1237
庸人自扰
庸人自扰 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 15:23

    To IMPORT:

    ype the following command to import sql data file:

    $ mysql -u username -p -h localhost DATA-BASE-NAME < data.sql
    

    In this example, import 'data.sql' file into 'blog' database using vivek as username:

    $ mysql -u sat -p -h localhost blog < data.sql
    

    If you have a dedicated database server, replace localhost hostname with with actual server name or IP address as follows:

    $ mysql -u username -p -h 202.54.1.10 databasename < data.sql
    

    OR use hostname such as mysql.cyberciti.biz

    $ mysql -u username -p -h mysql.cyberciti.biz database-name < data.sql
    

    If you do not know the database name or database name is included in sql dump you can try out something as follows:

    $ mysql -u username -p -h 202.54.1.10 < data.sql
    

    Refer: http://dev.mysql.com/doc/refman/5.6/en/mysqldump.html

    If you want a GUI tool then you could probably use SQLyog or navicat for this.

提交回复
热议问题