WordPress Error establishing a database connection (xampp)

Solution:1

If you have your old database file (.sql) then you can just

1.Run this link from your browser http://localhost/phpmyadmin.
2.Select Database which you want to upload the SQL file. (If no DB , create new database).
3.Click on Import option from top menu section and upload you files.

and for taking backup of your database on Xampp 1. Run this link from your browser http://localhost/phpmyadmin. 2. Select Database which you want to take backup of. 3. Click on Export option from top menu section and backup your files.

Solution:2

On the off chance that your old drive is totally organized, and you weren’t utilizing any kind of WordPress reinforcement module, then, at that point, no, you will not have the option to reconstruct the site. Sorry! As well as putting away your substance (posts/articles), your WordPress data set likewise stores data on which modules you were utilizing, so it is a basic piece of reconstructing any WordPress site.

Sometime later, you should send out your data set to a document (eg .sql), so you can import it on your new server/PC. You would accomplish this by either utilizing a WordPress module, or on XAMPP by utilizing phpMyAdmin. You could likewise do this with outsider applications, as SequelPro or MySQLWorkbench.

You ought to have your pictures and static resources saved – eg css records, transferred pictures, so you have something to begin with, assuming that you choose to reconstruct your site without the data set.

Solution:3

You want to introduce your wordpress site again with new information base. You previously lost it. Continuously reinforcement your wordpress site. You can reinforcement your wordpress site with this module and it’s free-
https://wordpress.org/plugins/updraftplus/