I am exporting MySQL database using python using command
import os
password = '1234'
os.system('mysqldump -u root -p%s ot_database > D:\\ot.sql' % password)
The code was executed with no errors and A ot.sql file is created but the file is empty There is no data in ot.sql
Please find the bug.
After Lot of research and debugging Finally I found the answer. os.system execute command line commands on some default directory but mysqldump is available in some other directory so I must change the current directory to the directory where mysqldump is available using command.....
mysqldump_dir = 'C:\\Program Files\\MySQL\\MySQL Server 8.0\\bin\\'
os.chdir(mysqldump_dir)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.