Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Armani's avatar
Level 17

Spatie Laravel Backup not working on server

I deployed my project to a shared host with Spatie Laravel Backup package but it is not working. I run this command:

php artisan backup:run --disable-notifications --only-db

It gives me this error:

Dumping database mountdu8_tamizandik...
Backup failed because The dump process failed with a none successful exitcode.
Exitcode
========
2: Misuse of shell builtins

Output
======
<no output>

Error Output
============
mysqldump: Got error: 1045: Access denied for user 'mountdu8_finance'@'localhost' (using password: YES) when trying to connect

my database name is mountdu8_tamizandik but it asks for user mountdu8_finance, I don't know why.

I don't have mountdu8_finance user on the server.

locally it works fine.

0 likes
41 replies
Sinnbeck's avatar

Can you show the database part of your env file (hide your password!) + the config for the used database in /config/database.php ?

Armani's avatar
Level 17

@Sinnbeck

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=mountdu8_tamizandik
DB_USERNAME=mountdu8_tamizandik
DB_PASSWORD=

and database.php

'mysql' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => 'InnoDB',
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],
        ],
Sinnbeck's avatar

@Armani Be aware that mountdu8_finance is the username, not the database

Can you try php artisan config:clear

Armani's avatar
Level 17

@Sinnbeck Yes I set it but I did not provide a first, I know that is a username.

I run php artisan config:clear but nothing changed, I think config is not cached at all

Sinnbeck's avatar

@Armani Can you check the /config/backup.php file, to see which databases it is set to backup?

Something like this

'databases' => [
                'mysql',
            ],
Sinnbeck's avatar

@Armani Can you try starting php artisan tinker on the server. Then put in config('database.connections.mysql');

Do you get the correct username here?

Sinnbeck's avatar

@Armani And if you run the command again, it still gives the wrong username?

Armani's avatar
Level 17

@Sinnbeck I logged in using SSH and tried to run the mysql command but it gives me error:

 syntax error near unexpected token `)'
Sinnbeck's avatar

@Armani How were you running the artisan command if you didnt log in with SSH? What was the command you ran?

Sinnbeck's avatar

Any chance there is a ) in your password?

Armani's avatar
Level 17

@Sinnbeck I run the same command you provided with my username and password and database name.

Yes I have )

Sinnbeck's avatar

@Armani Try this then

mysqldump -umyusr -p --database dbname

This should promt you for your password

Armani's avatar
Level 17

@Sinnbeck

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysqldump mountdu8_tamizandik -u mountdu8_tamizandik -p' at line 1
Armani's avatar
Level 17

@Sinnbeck I connected to server using SSH and PuTTY. and I logged into MySQL user mountdu8_tamizandik, then run the command

Sinnbeck's avatar

@Armani Skip this part and try again

I logged into MySQL user mountdu8_tamizandik

It is the same place where you run php artisan backup:run --disable-notifications --only-db

Armani's avatar
Level 17

@Sinnbeck This syntax worked for me:

 mysqldump -u mountdu8_tamizandik -p mountdu8_tamizandik
Sinnbeck's avatar

@Armani Just to make sure. You are running the php artisan backup:run --disable-notifications --only-db command in that same SSH connection?

Armani's avatar
Level 17

@Sinnbeck Yes it is the same connection, I can run all artisan commands on the server.

Sinnbeck's avatar

@Armani Then I sadly don't know. If mountdu8_finance is completely unknow to you, I have no clue where it comes from

Sinnbeck's avatar

Aha! I think I found the issue. The way the package works is by creating a conf file where it can read the credentials from. My guess is that mountdu8_finance is some other user on the server, and you are for some reason sharing that credentials file :/

I am currently investigating where it stores that file

1 like
Armani's avatar
Level 17

@Sinnbeck I even tried this:

$schedule->command(\Spatie\DbDumper\Databases\MySql::create()
        ->setDbName('mountdu8_tamizandik')
        ->setUserName('mountdu8_tamizandik')
        ->setPassword('')
        ->dumpToFile('dump.sql'))->daily();

But it gives me the same error.

Armani's avatar
Level 17

@Sinnbeck Yes it does:

 stream_get_meta_data(tmpfile())['uri']
=> "/tmp/phpo73Y0h"

>>> stream_get_meta_data(tmpfile())['uri']
=> "/tmp/phpGCzDQu"

>>> stream_get_meta_data(tmpfile())['uri']
=> "/tmp/phpvQaP4P"

Sinnbeck's avatar

@Armani Really really strange then! Are you using the latest version of the package? I am thinking if it was changed at some point.

It really seems that you are getting the file of some other user :/

Armani's avatar
Level 17

@Sinnbeck I'm using latest version:

"spatie/laravel-backup": "^8.1"

I can not access other user files. I don't understand.

Sinnbeck's avatar

@Armani From what I understand you dont know anything about mountdu8_finance and this is a shared server. And I assume that the host have given you this username mountdu8_tamizandik. So my guess is that you for some reason are getting the credentials file of another user (the user who owns mountdu8_finance). Why this is happening I don't know, but it is concerning.

Sinnbeck's avatar

@Armani Yes. But no other packages are creating a file like that I would assume.

Can you check one thing. When you log in using ssh. Is there a .my.cnf file present on the server?

Sinnbeck's avatar

@Armani does it contain a username and password? Are they yours? Does it suddenly start working if you rename that file?

Armani's avatar
Level 17

@Sinnbeck Yes it is not my username and password, Can I rename the file? Can I change the username and password?

Armani's avatar
Level 17

@Sinnbeck I edited the file and used my credentials and now it works fine.

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@Armani exelent. Removing or renaming it would probably solve the problem as well. But worrying that it had someone else's credentials.

Please mark a best answer to set the thread as solved

2 likes

Please or to participate in this conversation.