We use PHP and MySQL together without any problem on our website. and one day your PHP gives an error is database connection error this is not a big problem we can fix it easily.
Database Connection Errors
- Oops! Database is on a different URL
- Can't Connect database to Localhost
- Host Name does not match
- Database Is Corrupted
Repairing a Database in phpMyAdmin
If you use PHPmyadmin with your database you can repair your DB but make sure to take a backup of your database and just follow these steps.
- Log in to your web server(Cpanel).
- Click the phpMyAdmin icon
- Choose the affected database. If you only have one database, it should be chosen by default.
- In the main panel, you should see a list of the database tables. Click Check All.
- Choose the Repair Table from the drop-down menu.
Thanks, May above example help you.