mysql 导入导出

    技术2025-10-31  12

    一,mysql导出

    导出数据库的结构和数据:

    mysqldump -u root -p --skip-opt --skip-comments --complete-insert 'your db name' > 'your file name';

    只导出数据库的结构:

    mysqldump -u root -p -d --skip-opt --skip-comments --complete-insert 'your db name' > 'your file name';

    二,mysql导入

    1,create database db;

    2,use db;

    3,source '导出的文件';

    三,错误

    首是数据库中有视图的情况下,用show table status where comment='view';可以查看到新创建的视图。这时可能你会发现视图创建不成功,

    提示如Got error: 1449: The user specified as a definer ('root'@'') does not exist when using LOCK TABLES

    解决办法如下:

    1,登陆数据库mysql;

    2,grant all privileges on *.* to root@"%" identified by "密码"

    3,flush privileges;

    再重新导入。

    最新回复(0)