I'm going through some permission issues with my SELECT ... INTO OUTFILE statement.

After I log into my database and perform a simple export command, eg:

mysql> select * from XYZ into outfile '/home/mropa/Photos/Desktop/TEST.txt';

I recieve the respond:

ERROR 1 (HY000): 
Can't create/write to file '/home/mropa/Photos/Desktop/TEST.txt' 
(Errcode: 13)

However, after i simply write:

mysql> select * from XYZ into outfile 'TEST.txt';
Query OK, 8287 rows affected (0.73 sec)

The file is written in to the directory /var/lib/mysql/XYZ. I investigated the file /etc/apparmor.d/usr.sbin.mysqld where mysql appears to define the reading through and writting permissions however i don't really understand how to modify it.

How do i give myself permission to export a mysql table into any directory I love?

The problem is directory permissions. mysqld doesn't run as current_user. Add the mysqld user towards the group which has write permissions in your target sites (convenient, although not as secure) or remember to modify your target directory permissions pre and post you are writing the outfile.

This seems like you do not have access compared to that folder. You need to add mysql towards the group who owns that specific location.

I'm not sure under what user you're running mysql under, however,

chown mysql:mysql on /home/mropa/Photos/Desktop/logs indicates mysql user and mysql group may be the owner so has permission. After this you have to make certain the permissions include writing but that needs to be sufficient.

Chown Command

you may create a directory that's writable through the user that's running mysqld (usually "mysql") and write the file there. For intance:

chmod a+w /home/mropa/mysql

See https://wiki.ubuntu.com/DebuggingApparmor for info on debugging/crippling apparmor profiles.

It might not be an apparmor problem particularly. The consumer that mysqld is running as might not have permissions to create towards the folder you specified. Look into the permission around the destination directory/file.