今天在测试机导入数据库的备份文件,因为用户名有相同的,字段又是一个唯一性的索引导致失败了,接下来菜鸟资源网就大家介绍一下MySQL忽略错误继续执行下条命令,有需要的小伙伴可以参考一下:
1、错误提示:
[root@localhost home]# mysql -uroot -p itbianchenguc < itbianchenguc.dump_20200722.sql Enter password: ERROR 1062 (23000) at line 381: Duplicate entry '??' for key 'username'
2、解决方法:
导入的时候在数据库名称前面添加参数 -f ,-f是--force的缩写即如果有错误跳过去,继续执行下面的。
[root@localhost home]# mysql -uroot -p -f itbianchenguc < itbianchenguc.dump_20200722.sql Enter password: ERROR 1062 (23000) at line 381: Duplicate entry '??' for key 'username' ERROR 1062 (23000) at line 388: Duplicate entry '????' for key 'username' ERROR 1062 (23000) at line 395: Duplicate entry '???' for key 'username' ERROR 1062 (23000) at line 396: Duplicate entry '??' for key 'username' ERROR 1062 (23000) at line 421: Duplicate entry '???' for key 'username' ERROR 1062 (23000) at line 433: Duplicate entry '????' for key 'username' ERROR 1062 (23000) at line 436: Duplicate entry '???' for key 'username' ERROR 1062 (23000) at line 440: Duplicate entry '????' for key 'username' ERROR 1062 (23000) at line 441: Duplicate entry '???' for key 'username' ERROR 1062 (23000) at line 442: Duplicate entry '??' for key 'username' ERROR 1062 (23000) at line 449: Duplicate entry '???' for key 'username' ERROR 1062 (23000) at line 454: Duplicate entry '??' for key 'username' ERROR 1062 (23000) at line 465: Duplicate entry '????' for key 'username' ERROR 1062 (23000) at line 466: Duplicate entry '????' for key 'username'
上面的命令执行完就可以看到数据库导入成功,忽略的错误也显示出来了。