MySQL DROP all tables, ignoring foreign keys

前端 未结 24 2721
醉梦人生
醉梦人生 2020-12-02 03:44

Is there a nice easy way to drop all tables from a MySQL database, ignoring any foreign key constraints that may be in there?

24条回答
  •  春和景丽
    2020-12-02 03:51

    Drop all the tables from database with a single line from command line:

    mysqldump -u [user_name] -p[password] -h [host_name] --add-drop-table --no-data [database_name] | grep ^DROP | mysql -u [user_name] -p[password] -h [host_name] [database_name]
    

    Where [user_name], [password], [host_name] and [database_name] have to be replaced with a real data (user, password, host name, database name).

提交回复
热议问题