Search code examples
mysqlexportcloud9-ide

How can I export a MySQL Database from Cloud9?


How can I export a MySQL Database from Cloud9, the online development IDE in the cloud. I was able to import a database, but I still haven't figured out how to export it, or download it to my computer, or anywhere else for that matter.


Solution

  • mysql-ctl cli
    GRANT ALL PRIVILEGES ON *.* TO <username>@localhost;
    SHOW VARIABLES LIKE 'socket';
    quit;
    
    mysqldump -u<username> --protocol=tcp -S /home/ubuntu/lib/mysql/socket/mysql.sock  --all-databases > db.sql
    

    There were two tricks. First, mysqldump didn't let me run it as the regular root user, so I created my own username with full privileges. Then, I looked up what socket it ran under. Then, I specified that it should run with the tcp protocol. That exported out all my sql tables.