In this tutorial, we will see how to connect to a MySQL database that prohibits access when you have PHP 7 with MySQL 8.

![](http://34.207.224.239:3000/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBdXhNIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--4e42a0dd217318554ee74f377f2e44795bb0e3fe/1.png)

\
First, you must follow the manual [Creating a new MySQL User.](https://help.scriptcase.net/portal/en/kb/articles/how-to-connect-to-mysql-8-0)

1- Once the creation of the new user has been done, you must go to the path to edit the MySQL configuration file.

Windows: C:\ProgramData\MySQL\MySQL Server[VERSION_HERE]\ my.ini,\
OBS: The ProgramData folder is a hidden folder, in order to see it you must access the option Folder > Show hidden files and folders.\
Linux: /etc/mysql/my.cnf

2- Then edit the file and where it says

default-authentication-plugin = caching_sha2_password.

Change to

default-autenticação-plugin = mysql_native_password

If you don't find the line above, add this snippet:

```
[mysqld]  
 default_authentication_plugin= mysql_native_password
```

Finally, restart the MySQL service in order to enable the new settings.