Posted: . At: 10:12 AM. This was 5 years ago. Post ID: 13468
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


Export a database from MySQL when it is using the secure file privilege setting.


MySQL can be a pain to use when it is is running with the –secure-file-priv option and it cannot export a database to your home folder. But there is a way around this. Execute this query in MySQl.

4.4 Mon Aug 19 jason@Yog-Sothoth 0: $ mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.27-0ubuntu0.18.04.1 (Ubuntu)
 
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
mysql> SELECT @@secure_file_priv;
+-----------------------+
| @@secure_file_priv    |
+-----------------------+
| /var/lib/mysql-files/ |
+-----------------------+
1 row in set (0.00 sec)

This query tells us the directory that MySQl is allowed to write to. Now I can export a database using MySQL as root.

sudo mysqldump --user=root --password=mysecurepassword -T /var/lib/mysql-files/ bejiitas_wrath wp_makronposts;

This is how to export a database without disabling the security of the MySQL database management system. Now just use Midnight Commmander and change ownership of the files to your user after copying them to your home directory. This is an easy way of exporting a database, but it requires root/sudo access to the machine to work.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.