Solution :
You need to open your terminal and run the bbellow command.
sudo apt-get install mysql-server
After that if you are running the PHP then you will also need to install a php module for your mysql 5 with below command:
sudo apt-get install php5-mysql
OR
Please use "mysqli_connect" as shown below :
$con = mysqli_connect("127.0.0.1","root","pass","your_database");
it will certainly work, I have fixed my problem with this .
OR
If you are using the Windows10, PHP 7.2 and try to connect to mysql. If above error occurred
Then please do the following steps to get it corrected.
1. Go to your PHP installation folder,
2. Check for your php.ini file, (Only dev, prod file is there, then one of your file as php.ini file)
3. Look for the "extension=mysqli" and remove a ";" before it.
4. Look for the "extension_dir" and mentioned your path of "ext" directory.
5. Finally restart the application.
Hope this will help you in resolving your issue.