0

I have an installation of Snipe-IT on FreeBSD 11.3 with MySQL 5.7.27, PHP 7.3.7, and Apache 2.4.39_1.

I'm encountering this error in ~snipe-it/storage/logs/laravel.log:

[2019-10-25 13:13:24] production.ERROR: PDOException: SQLSTATE[HY000] [1045] \
  Access denied for user 'snipeuser'@'localhost' (using password: YES)  \
  in /usr/local/www/apache24/snipe-it/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:27

The problem is that localhost is not the value defined for DB_HOST in Snipe-IT's .env configuration file.

My Apache 2.4 config has this VirtualHost entry:

<VirtualHost *:80>
    ServerName snipeit.example.edu
    DocumentRoot /usr/local/www/apache24/snipe-it/public/

    <Directory /usr/local/www/apache24/snipe-it/>
            <RequireAll>
#                    Require not ip 10.10.229.71
                    Require all granted
            </RequireAll>
            AllowOverride None
            Options None
    </Directory>

    RewriteEngine On
    # From public/.htaccess
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
    RewriteRule ^ /index.php [L]

</VirtualHost>

My .env file for Snipe-IT is in /usr/local/www/apache24/snipe-it/. It contains these DB_* settings:

DB_CONNECTION=mysql
DB_HOST=10.10.231.22
DB_DATABASE=snipeit
DB_USERNAME=snipeuser
DB_PASSWORD=mypassword
DB_PREFIX=null
DB_DUMP_PATH='/usr/local/bin'
DB_CHARSET=utf8mb4
DB_COLLATION=utf8mb4_unicode_ci
DB_SOCKET=/tmp/mysql.sock
DB_SSL=false
DB_SSL_KEY_PATH=null
DB_SSL_CERT_PATH=null
DB_SSL_CA_PATH=null
DB_SSL_CIPHER=null

MySQL is set up and working. I can successfully initiate a command-line SQL client using the hostname, username, password and database name shown above to access the snipeit database. The snipe database exists but is otherwise empty.

# mysql -h 10.10.231.22 -u snipeuser -p snipeit
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 141
Server version: 5.7.27-log Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

snipeuser@10.10.231.22 [snipeit]> 

The Snipe-IT documentation mentions that certain configuration information is cached, and that cache may need to be cleared after making changes to the .env file. Running:

# composer dump-autoload
# php artisan config:clear
# php artisan view:clear
# php artisan cache:clear
# php artisan route:clear
# service apache24 restart

When I aim my browser (Firefox) at the Snipe-IT target URL, I get NOTHING, a blank white screen. When I edit .env to include:

APP_DEBUG=true

and then refresh the page in Firefox, I get an exception backtrace, part of which says:

Access denied for user 'snipeuser'@'localhost' (using password: YES)

The fact that I can turn APP_DEBUG on and off gives me hope that I have the .env file in a directory where Snipe-IT is finding it.

However, I can't get Snipe-IT to pick up on my DB_HOST value, even after running all the config/cache-clearing stuff. It still is trying to connect to localhost even though the .env file says 10.10.231.22.

What do I need to change in order to get Snipe-IT to use the correct DB_HOST value?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.