Laravel - Which user creates log files - mysql

My issue is I've a laravel web application and in the storage folder I'm logging the slow SQL queries, but they do not appear. In laravel.log I can see the following error:
[2019-02-22 07:23:21] dev.ERROR: file_put_contents(/var/www/html/com.mywebsite/storage/logs/sql/2019-02-22-slow-log.sql): failed to open stream: Permission denied {"userId":40,"email":"a.user#somewhere.com","exception":"[object] (ErrorException(code: 0): file_put_contents(/var/www/html/com.mywebsite/storage/logs/sql/2019-02-22-slow-log.sql): failed to open stream: Permission denied at /var/www/html/com.mywebsite/vendor/mnabialek/laravel-sql-logger/src/SqlLogger.php:179)
I'm running this on CentOS 7 linux with NginX and PHP-FPM. Both of them runnin with user called web and the permissions on all the files and folders is web:web. However, I saw one slow-query log file, with the permission root:web. What gives?

Oh yeah! I have found the issue. One of my former sys.operators wrote the cronjob and I didn't pay attention. He wrote it for the sudo user and not the web user. It was a job to run certain PHP commands. That is why the log file appeared with root permissions, but later on, the laravel application was unable to write it. Thanks for the help. :)

Related

Win Server 2019 - XAMPP - MYSQL Access denied for user ''#'localhost' (using password: NO)

I've been browsing the web and this site from other users which have had this issue and reading the comments to resolve however I've not had much luck and i'm going bonkers trying to work out the issue.
I have two servers - Win Server 2019 and both use XAMPP with Apache and MYSQL, the first server (1) has been running for over a year perfectly fine, however I'm setting up another server (2) to use as a test environment but with a fresh install of windows, xampp along with the Apache/MYSQL modules.
I'm using Invision Community application but I'm getting this upon the first page of installation:
MySQL Requirements
Fatal error: Uncaught mysqli_sql_exception: Access denied for user ''#'localhost' (using password: NO) in C:\xampp\htdocs\ips4.php:317 Stack trace: #0 C:\xampp\htdocs\ips4.php(317): mysqli->__construct('localhost') #1 C:\xampp\htdocs\ips4.php(340): my_mysqli->__construct('localhost') #2 {main} thrown in C:\xampp\htdocs\ips4.php on line 317
IPS4.php is just a file to state whether the server meets all the requirements for the application.
I've then compared MYSQL on (1) to the install on (2) and I've matched the details, given privileges to "root" user on all of the available databases within PHPMYADMIN, granted full grants and then reloaded them, restarted MYSQL and Apache and still same issue.
Normally the Invision software continues through to then request the database details, user details etc. but it hasn't got to that point yet.
The only differences I can see between both servers is (1) is running PHP 7.3.7 | Apache 2.4.39 | MySQL 5.0.12 and server (2) is running PHP 8.2.0 | Apache 2.4.54 | MySQL 8.2.0
I was hoping I would just install XAMPP and then transfer the files to install the software and then configure it to choose which DB/User and then install and get started but apparently not.
ROOT doesn't have a password on (2) but does on (1), when I add a password to (2), I'm then unable to access PHPMYADMIN and doesn't ask for a password to log in. I've spent a few hours today trying to resolve this but now I think I'd like some advice. Many thanks
Setting root password, then flushing privileges, granting full permissions on all databases, copying the mysql files from server (1) to server (2). uninstalling XAMPP and reinstalling.
I don't recall ever needing to do anything for permissions when I setup this software on server (1). I've also installed this software on a few linux servers but didn't enjoy using linux so I stopped using it.
EDIT: It seems it's using MariaDB 10.4.27
Set a password for root on (2).
Change the phpMyAdmin config.inc.php file,change
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = '';
$cfg['Servers'][$i]['password'] = '';
then phpMyAdmin will throw a login dialog and ask for a user/password
That should sort out the phpMyAdmin issue.
Big Note: You really should not be using the root account for any app/website access. Instead you should create a user account in MySQL/mariaDB one for each app/website that has access only to the database(s) required for that app/website. (Basic Security)
There was a user called "Any" hostname "%" which looks to be what was causing the issue, I gave it access to all databases (most likely wrong thing to do but it's internally accessed only - no access outside of our network).
This got rid of the error
Thanks for your help

Why can't I set up my Kalabox Drupal Site? SQLState[Hy000] error

I have a fresh install of Ubuntu 14.04 in Hyper-V, a fresh install of mysql and user 'root'#'localhost' with 'password'. I created a database called 'drupaltest'. Yet when I start up a kalabox Drupal Site, I try enter that information in and I get this error:
Failed to connect to your database server. The server reports the following message: SQLSTATE[HY000] [2002] No such file or directory.
Can you help me figure out what's going on with it?
You can find the related information to your question here. From this you find your database related information following these steps:
Use the Terminal option from the dropdown to access the location of the PHP app that you already created. In this example it is the second option for the existing new Drupal 8 installation.
This will open the terminal navigated to the kalabox container. confirm that it is in the parent directory. Check for the kalabox root files and directories; cli.yml, code, config, dockerfiles, etc.. They should resemble something like this:
You can see that the kalabox container is located in my user directory.
use the kbox services command to print the services available to the container. If it doesn't work you may not be in the parent directory of the container and would refer back to step 2.
use the mysql database that comes with your kalabox site!

Backup database query with OS error 5

I'm trying to run a backup query:
BACKUP DATABASE MY_DATABASE TO DISK='C:\Users\me\Desktop\POD2013-05-14.bak'
But I get the following error:
Cannot open backup device 'C:\Users\me\Desktop\POD2013-05-14.bak'. Operating system error 5(failed to retrieve text for this error. Reason: 15105).
I thought it has to do with permissions, but log in as sa and Administrator (Win Auth) doesn't solve the problem.
Can anyone help me with this?
You need to check the security permissions on the folder you are trying to backup. Make sure the service account (Network Service) has write permissions.
I think your problem might be okay.

Unable to create indexes in Sphinx after an emergency server restart [Can't create TCP/IP socket]

I'm trying to execute the command in the Windows console:
C:\SphinxSearch\bin\indexer --all --config C:\SphinxSearch\sphinx.conf
But I get an error:
ERROR: index 'indexname': sql_connect: Can't create TCP/IP socket
(10093) (DSN=mysql://root:*#localhost:3306/test).
A data source is mysql. Before the server restart everyone works fine.
How can I fix it?
I'm having the same error 10093. It's a windows error code by the way. In my case it occurs when trying to run the indexer through the system account via a scheduled task. If I'm running it directly as administrator, there's not a problem.
According to the site above:
Either your application hasn't called WSAStartup(), or WSAStartup() failed, or--possibly--you are accessing a socket which the current active task does not own (i.e. you're trying to share a socket between tasks).
In my case I'm thinking it might be the last one, some security problem due to user SYSTEM being used in my scheduled task. I was able to solve it by using my admin user instead: in the scheduled task, I set to use my local admin account with the option to "Run when user is logged on or not" and "Do not store password". I've also checked "Run with highest privileges". This seems to have done the trick as now my indexes are rotating on schedule.

symfony database access configuration problem

I just joined a web dev project that uses Symfony 1.4 on CentOS 5.4 with MySQL. The server is down. My first task in the project is to get it back up. I don't know a lot about Symfony.
The Apache server log says
Access denied for user 'root'#'localhost' (using password: NO)
From all I can tell, the database access configuration is stored in
/var/www/html/<project name>/config/databases.yml
and for some reason, there's also some config in
/var/www/html/<project name>/config/propel.ini
There was no password for user root in either of the files, so I thought adding it and restarting Apache would finx the issue. It does not, the error message stays the same. I might be looking at the wrong config files, but I can't find any other.
Any wild guesses how to fix this ?
Cheers,
ssc
OK, I know now what I did wrong: The password indeed has to be added to databases.yml, but whenever the configuration is changed, the symfony cache needs to be cleared by executing
./symfony cc
in the /var/www/html/<project name>/ folder.
You are right, the database config file is stored at /WEB/project/config/databases.yml
You can also try to run the configure:database command from the symfony command line tool.
php symfony configure:database "mysql:host=DBHOST;dbname=DBNAME" USER PASS
A getting started guide, and much more can be found at: http://www.symfony-project.org/jobeet/1_4/Propel/en/