zoukankan      html  css  js  c++  java
  • 常用mysql导入导出数据的命令

    To export

    导出指定db_name的数据:

    $ mysqldump -u [uname] -p[pass] db_name > db_backup.sql

    导出整个库的数据:

    $ mysqldump -u [uname] -p[pass] --all-databases > all_db_backup.sql

    导出指定表的数据

    $ mysqldump -u [uname] -p[pass] db_name table1 table2 > table_backup.sql

    导出打包的数据文件(如果文件很大)

    $ mysqldump -u [uname] -p[pass] db_name | gzip > db_backup.sql.gz

    导出远程机器上的数据:

    $ mysqldump -P 3306 -h [ip_address] -u [uname] -p[pass] db_name > db_backup.sql

    如果只导出sql语句,不需要数据,可加参数 --no-data

    To import

    Type 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 Sathish 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
  • 相关阅读:
    .net正在终止线程异常
    js判断客户浏览器类型,版本
    C#中ToString格式大全
    WPF TextBox 搜索框 自定义
    C#:获取设备电量相关信息
    C#中的委托与事件并存的理由
    WPF中的Pack URI
    SQLServer中的数据库备份和还原
    使用Aspose.Cells读取Excel
    SQLServer存储过程事务用法
  • 原文地址:https://www.cnblogs.com/ahang/p/6740034.html
Copyright © 2011-2022 走看看