✓ Solved

Wordpress: wp-config - Database connection not working. File destroyed after downloading.

Hello friends

I have a big problem.
I installed wordress from marketplace (Ubuntu 22.04)

Worked fine, after I wanted to download a backup from wp-config file. But Connection lost and the file was destroyed. So I didnt come to see what really is in file. Maybe misstyped with some date to connect to database.

Now, question is how to fix that?
Can I find the wordpress database name, user, password
Or how can I change that to put in the correct files on wp-config to get database connection again?

Normaly I am working with CPANEL, so that is easy. But here on Linode nice servers, but I have to learn some of that hints ;)

Thanks for helping
warm regards
Michael

13 Replies

✓ Best Answer

You are my hero so far with your idea.

So meanwhile I have the correction in root databse and wordpress database with a password set

use mysql;
flush privileges; // This before and then alter code was working
ALTER USER 'wordpressuser'@'localhost' IDENTIFIED BY 'newPass';

just now I have in Wordpress added user and password.
The connection error before is gone.

But I have a new error. So something seems to bee with privileges or so

Connection error. Visit the admin area for more details or open the > config.php file and check the database information. Message: Access > denied for user 'wordpress'@'localhost' (using password: YES).

"after I wanted to download a backup from wp-config file."

What does that mean? wp-config is used to hold the connection data between the application and the database. Did you change any of the settings in there?

"how can I change that to put in the correct files on wp-config to get database connection again?"

If you know all of the settings simply SFTP into your server, find the directory that WP is in and using any editor… usually built-in to the SFTP client.. change these settings in wp-config:

/** The name of the database for WordPress */
define( 'DB_NAME', 'xxxxxxxx' );
/** Database username */
define( 'DB_USER', 'xxxxxx' );

/** Database password */
define( 'DB_PASSWORD', 'xxxxxx' );

/** Database hostname */
define( 'DB_HOST', 'might-be-localhost' );  

If you don't have a local SFTP client (Filezilla is free) you can SSH in and use the nano or vi editor to make those changes.

Thanks.
But I meant, I installed with the Linode Setup Wordpress installation. So far, I normaly did it with Wordpress installation process.
So I wanted to download the created wp-config file via sftp.
But a connection break or error breaks file, so I dont know really what the installation puts into file. Maybe I had a misspelling.

So, I have file, but I need to change DB-USER and DB-PASSWORD
DB-NAME should be automated wordpressdb

So, my question and problem is how can I change user and dbpassword in linux or in a file via sftp. So that I can put that into wp-config file and get new connection.

Any workaround maybe.
I searched a lot, but I didnt find any usefull for Ubuntu
Even the Docs here not really good.

Hope my problem is described better
Thanks so far

Warm regards
Michael

Thanks.
But I meant, I installed with the Linode Setup Wordpress installation. So far, I normaly did it with Wordpress installation process.
So I wanted to download the created wp-config file via sftp.
But a connection break or error breaks file, so I dont know really what the installation puts into file. Maybe I had a misspelling.

So, I have file, but I need to change DB-USER and DB-PASSWORD
DB-NAME should be automated wordpressdb

So, my question and problem is how can I change user and dbpassword in linux or in a file via sftp. So that I can put that into wp-config file and get new connection.

Any workaround maybe.
I searched a lot, but I didnt find any usefull for Ubuntu
Even the Docs here not really good.

Hope my problem is described better
Thanks so far

Warm regards
Michael

But a connection break or error breaks file, so I don't know really what the installation puts into file. Maybe I had a misspelling.

I'm still a bit lost. Are you saying you cannot get into your server either via an (S)FTP client OR you can get in via SSH from your terminal or from LISH on your Linode manager website?

Unless you can get into the server via FTP or SSH there is no way I know of to change the settings in the wp-config.php file.

OR… are you saying you were able to download the wp-config vile but don't know how to change it?

OR… are you saying you CAN get into into the server via FTP but don't know what to do?

I'll help you but I need to understand the problem a bit better.

I can get into server via FTP and change wp-config. That is no problem.

The problem is, that I set up wordpress via linode. On installationprocess, there is no own database and database user creation by myself. This happend automated. So I wanted to backup wp-config file after to see what installation process has written into it.
Then, connection break on WinSFTP I used. Reconnection and download, the file was damaged, the content in file was deleted. I dont know why?

anyway.
Linode has no easy way to change in dashboard - like cpanel - I used before on other server to change databaseuser and password and database … On the way to learn some linux again, after years, I tried to find how database works on command line, but anywhay I dont know how to change the database password. Tried any tutorials I found the weekend, to change a password. But even you need as root, another root login for database. And you cant - maybe - not change it with main root. Even because I misstyped maybe the database password in linode wordpress installation process. yay, 2 bad errors in a row, so I am in this situation to bring back a wordpress website I even migraded after installation in wordpress admin and before new wp-admin.config file backup.

So, long story, same problem.
No Database Connection, because of maybe wrong database password I cant change or didnt find a solution.

Event tried this
https://www.cyberciti.biz/faq/mysql-change-user-password/

But after first line I got
ERROR 1045 (28000): Access denied for 'user' @'localhost' (Using password: YES)

So even root password to login mysql not working to change wordpress (user/password) to get connectio again.

I can get into server via FTP and change wp-config. That is no problem.

The problem is, that I set up wordpress via linode. On installationprocess, there is no own database and database user creation by myself. This happend automated. So I wanted to backup wp-config file after to see what installation process has written into it.
Then, connection break on WinSFTP I used. Reconnection and download, the file was damaged, the content in file was deleted. I dont know why?

anyway.
Linode has no easy way to change in dashboard - like cpanel - I used before on other server to change databaseuser and password and database … On the way to learn some linux again, after years, I tried to find how database works on command line, but anywhay I dont know how to change the database password. Tried any tutorials I found the weekend, to change a password. But even you need as root, another root login for database. And you cant - maybe - not change it with main root. Even because I misstyped maybe the database password in linode wordpress installation process. yay, 2 bad errors in a row, so I am in this situation to bring back a wordpress website I even migraded after installation in wordpress admin and before new wp-admin.config file backup.

So, long story, same problem.
No Database Connection, because of maybe wrong database password I cant change or didnt find a solution.

Event tried this
https://www.cyberciti.biz/faq/mysql-change-user-password/

But after first line I got
ERROR 1045 (28000): Access denied for 'user' @'localhost' (Using password: YES)

So even root password to login mysql not working to change wordpress (user/password) to get connectio again.

OK, as I understand the problem,

  1. The password (and user?) in wp-config.php is wrong.

  2. You don't know the user or root password to your mySQL database in order to correct wp-config.

Thus, your site does not work. If the above is correct you might find something to help in this search:

https://www.google.com/search?q=How+to+access+MySQL+database+without+password%3F&sa=X&ved=2ahUKEwigs-6c1eT-AhVmIDQIHWnqAL4Qzmd6BAgYEAY&biw=1366&bih=955&dpr=2

or maybe this one:

https://www.google.com/search?q=how+to+hack+mysql+database+password&oq=how+to+hack+mysql+database+password&aqs=chrome..69i57.12679j0j1&sourceid=chrome&ie=UTF-8

You can try this. I don't know if it will work.

systemctl stop mysql
sudo mysqld_safe --skip-grant-tables &

Now you can access the mysql server without a password.

mysql -uroot

Add a new password to the root user in the mysql shell

use mysql;
update user set password=PASSWORD("newpassword") where User='root';
flush privileges;

Now restart it in normal mode again and it will work with the new password.

systemctl stop mysql
systemctl start mysql

I found the above here. They might be some other code of value as well: https://askubuntu.com/questions/915585/how-to-login-mysql-shell-when-mysql-have-no-password

Yeah we are close.
Same stuffs in a different way I tried. Your seems to be better.

Working until:

update user set password=PASSWORD("anypassword") where User='root';

then:

ERROR 1348 (HY000): Colum 'Password' is not updateable

Connection error. Visit the admin area for more details or open the > config.php file and check the database information. Message: Access > denied for user 'wordpress'@'localhost' (using password: YES).

It looks like something in wp-config.php does not match the database.

See if you find something here:

https://tinyurl.com/yybmjb8p

OK DONE! FINISHED

I dont know, what the problem was, after some serverrestarts and meanwhile having a lunch, coming back and page working fine lol

So
@acanton77 Thanks so much for helping with your helpfull ideas.

you are on telegram or else to connect?

Cheers
now one bottle beer to you
Michael

Glad you got it working.

Now make a MySQLDump (backup) of your database. I use phpMyAdmin to do it but you can do it from the terminal or maybe via your c-panel.

No matter how you do it, just do it! And make sure you have the database credentials written down and saved somewhere.

[editorial]
I've found that using so-called 'one-click' installers or installers from different 'panel' utilities as well as 'marketplaces' can introduce a ton of issues… especially for WordPress. WP is rather simple to install and I always suggest people learn how and do it that way.

YMMV
[/editorial]

ANC
NewMediaCreate

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct