Yes you can do this.
You can add timestamp data to the Mosquitto output by doing the below for example:
mosquitto_sub -v -t '#' | xargs -d$'\n' -L1 sh -c 'date "+%D %T $0"'
You could obviously output this to a text file as well via doing the following:
mosquitto_sub -v -t '#' | xargs -d$'\n' -L1 sh -c 'date "+%D %T $0"' > /var/tmp/My_Mosquitto.log
You can view the log file via:
cat /var/tmp/My_Mosquitto.log
You would then have to write say a php script that reads this text file and adds the data to a database table.
Another (much better) option would be to use node.js to log all the MQTT data to a mysql database table. There are examples of how to do this all over the internet - this is how I do it.