There are a few options to export the rows of your moodle tables into the excel/CSV files:
Uses the syntax of SELECT INTO files and runs the script in the database server. Example:
1 SELECT id,name,value
2 FROM config
3 INTO OUTFILE '/var/lib/mysql-files/config.csv'
4 FIELDS TERMINATED BY ','
5 ENCLOSED BY '"'
6 LINES TERMINATED BY '\n';
Please ensure the user of the database has access to the moodle tables and you can check the accessible directory to write in the parameter secure_file_priv using the following command:
1 mysql> show global variables like 'secure_file_priv';
2 +------------------+-----------------------+
3 | Variable_name | Value |
4 +------------------+-----------------------+
5 | secure_file_priv | /var/lib/mysql-files/ |
6 +------------------+-----------------------+
7 1 row in set (0.00 sec)
Uses third-party database GUI (eg: DBEaver, Heidi SQL, Navicat). Usually, they provide the export feature to the CSV files as well.