Home > Blockchain >  how to set mysql general_log_file path to shared folder in laravel homestead
how to set mysql general_log_file path to shared folder in laravel homestead

Time:06-08

I'm using laravel homestead, and for purposes I need to have quick access to mysql general_log_file in my windows shared folder. I started with this:

mysql> SET GLOBAL general_log_file = '/home/vagrant/code/mysql.log';

I also removed secure_file_priv from mysql setting, now I get:

mysql> SHOW VARIABLES LIKE "secure_file_priv";
 ------------------ ------- 
| Variable_name    | Value |
 ------------------ ------- 
| secure_file_priv |       |
 ------------------ ------- 

I even gave Give Root Privileges to mysql via this method, but I still get this error:

Can't create/write to file '/home/vagrant/code/mysql.log' (OS errno 13 - Permission denied)

while trying:

mysql> SET GLOBAL general_log = 'ON';

any idea how can I solve this irritating problem?

CodePudding user response:

I know of two things to check that are likely causes. I've experienced both of these in a vagrant environment.

  1. The directory is not writeable by the Linux uid of the mysqld process.

  2. The Linux kernel is restricting the paths accessible to mysqld through Apparmor (Ubuntu or Debian) or SELinux (CentOS or RHEL). The error reported is a permission error, even if the file permissions appear to allow the mysql user to write to that location. You must either disable the apparmor/selinux or else configure it to allow the alternative location.

    Since you're only using a VM, I'd just disable it, unless you would like to learn how to configure it in case you need to do that in a non-VM environment.


PS: secure_file_priv is totally irrelevant to this issue. That option affects only LOAD DATA INFILE and SELECT ... INTO OUTFILE.

  • Related