How to generate DDL for all tables in a database in MySQL

给你一囗甜甜゛ 提交于 2019-12-02 16:33:19
AJ.

You can do it using the mysqldump command line utility:

mysqldump -d -u <username> -p<password> -h <hostname> <dbname>

The -d option means "without data".

@tftdias above made a comment that is partially correct:

The issue was the space between the -p and 'pps' as the password. You can absolutely freetext your password on the command line. You just shouldn't, as a general security rule. In linux, with a proper configuration, you can add a space (" ") BEFORE the first character on your command line, and that line will not enter into 'history'. I would recommend that whenever you cleartext your password (don't do it!), that you at least put a space first so that the password is not in visible history.

You must get list of all the tables in database and then run this query. check this link to get list of all tables: http://php.net/manual/en/function.mysql-list-tables.php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!