ER_NOT_SUPPORTED_AUTH_MODE - sails 1.0 and MySQL 8.0 - mysql

I'm trying to connect SailsJS with MySQL
default: {
adapter: require('sails-mysql'),
url: 'mysql://root:root#localhost/ventas'
},
But whenever I do a 'sails lift' I get the following error:
error: A hook (`orm`) failed to load!
error:
error: { error:
{ Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
at Handshake.Sequence._packetToError (C:\ticket\node_modules\mysql\lib\protocol\sequences\Sequence.js:48:14) }
I'm just using the web app template that comes with sails with no added code.
Any ideas?

The problem may be with encrypting the password. MySQL 8.0 uses caching_sha2_password. You need change it to mysql_native_password:
ALTER USER 'user' identified with mysql_native_password BY 'password';

The problem is coming from mysql, you need to change the plugin to mysql_native_password and then flush privileges;, see here and here.

Set your password to one with Upper case , lower case, numeric and a special character in it with 8 letters long .

Related

ER_NOT_SUPPORTED_AUTH_MODE issue with Keira3

I'm having an issue connecting to the SQL database using the program Keira3 (version 3.0.2).
Error: Client does not support authentication protocol requested by
server; consider upgrading MySQL client
Code: ER_NOT_SUPPORTED_AUTH_MODE Errno: 1251 SQL State: 08004
Unfortunately the mysql library used by Keira3 does not support the new Mysql 8.0 authentication protocol, to change it you can run:
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
There is an open issue for this problem.

Sequelize does not suport the MySQL 8 autentication protocol and I'm not getting how to change this protocol

I'm trying to migrate a db with Sequelize working with MySQL 8.0.15, but I'm not able to do that. I keep receiving this error message.
Sequelize CLI [Node: 10.15.0, CLI: 5.4.0, ORM: 5.3.5]
Loaded configuration file "config/config.json".
Using environment "development".
ERROR: Client does not support authentication protocol requested by server; consider upgrading MySQL client
I've tried every single solution for this problem. The thing is when i try to change the MySQL root password the message i get is this one:
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
Then I did try to change the password validate policy following this procedure
https://dev.mysql.com/doc/refman/5.6/en/validate-password-installation.html
then MySQL crashed cause it's deprecated. Then I tried this one
https://dev.mysql.com/doc/refman/8.0/en/validate-password-installation.html
Then I got this
mysql> INSTALL COMPONENT 'file://component_validate_password';
ERROR 3529 (HY000): Cannot load component from specified URN:
'file://component_validate_password'.
Then I checked where the component is
ls /usr/lib64/mysql/plugin/component_v*
/usr/lib64/mysql/plugin/component_validate_password.so
Anyone can help? I'm realy out of options, now!
Thanks in advance
If you want to use MySQL 5.x style authentication, typically all you have to do is add this to your my.cnf:
[mysqld]
default_authentication_plugin=mysql_native_password
Do this before adding any users. Only use users for connecting via Sequelize, never root.
If you are using MySQL 8.0 then https://dev.mysql.com/doc/refman/5.6/en/validate-password-installation.html then this shouldn't work.
Have used mysql_secure_installation and installed the validate_password_component then?
If yes, in that case, the plugin must already be installed and all you need to do is set validate_password related parameters in the options file (default /etc/my.cnf) and some options require a server restart.
For those who cannot edit system variables (for instance, if you're using a managed database in AWS or DigitalOcean), this works as well:
ALTER USER 'foo'#'bar' IDENTIFIED WITH mysql_native_password BY 'password';
flush privileges;
Or, if you cannot run flush privileges; like me:
DROP USER 'foo'#'bar';
CREATE USER 'foo'#'bar' IDENTIFIED WITH mysql_native_password BY 'password';
GRANT INSERT, SELECT, ... ON mydb.* TO 'foo'#'bar';

MySQL plugin Standard is not loaded

I was trying to reinstall MySQL server 8.0 in order to use legacy authentication method, but got the following error in log when installer was attempting to start the server:
MySQL error 0: Authentication to host 'localhost' for user 'root'
using method 'mysql_native_password' failed with message: Plugin
'Standard' is not loaded
How can i fix it?
caching_sha2_password is the default authentication mechanism in 8.0. So use a client that support this. Or using the mysql-8.0 client, create a new user using CREATE USER:
CREATE USER 'vyacheslav'#'localhost'
IDENTIFIED WITH mysql_native_password BY 'password';

PDOException::("PDO::__construct(): Unexpected server respose while doing caching_sha2 auth: 109") with MySQL 8 / PHP 7.2 / Laravel

I just installed my dev environnement.
When I try to connect mysql db via SequelPro, I get:
Authentication plugin 'caching_sha2_password' cannot be loaded
As stated in: Authentication plugin 'caching_sha2_password' cannot be loaded, I ran:
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY '';
Then I could connect my DB via SequelPro
But when I execute Laravel Command:
php artisan migrate
I get:
PDOException::("PDO::__construct(): Unexpected server respose while doing caching_sha2 auth: 109")
What should I do now ?
PD: I use Laravel Valet on Mac, and Laravel 5.6.
You must alter use in your laravel app via shell with mysql command
ALTER USER 'user'#'localhost' IDENTIFIED WITH caching_sha2_password BY 'your password';
ALTER USER 'user'#'%' IDENTIFIED WITH caching_sha2_password BY 'your password';
the problem is good for safety, mybe.
but I use the command solve the problem:
ALTER USER root#localhost IDENTIFIED WITH caching_sha2_password BY 'password';
restart mysql
try now
Hope you will not see this error again.
After using $ mysql -uUser -pPa$$w0rd the MySQL connection could be opened with PHP using mysqli_real_connect() or PDO
Make sure that the User has caching sha2 password active, not a native password. (PHP 7.2.9-1, MySQL 8.0.12)
When changing to a native password PHP says
mysqli::real_connect(): Unexpected server respose while doing caching_sha2 auth: 109
With caching sha2 password active i always get:
mysqli::real_connect(): (HY000/1045): Access denied for user 'User'#'localhost' (using password: YES)
So tried to login from Shell using $ mysql, which succeeded, after this, i was able to connect with PHP. Seems like a Bug in the PHP mysqlnd.
Implementing a shell_exec('mysql -u'.$user.' -p"'.$password.'" -e quit > /dev/null 2>&1'); right before opening the MySQL connection, solves the issue, by now, for me.
Rebooting or restarting the MySQL Service, resets the cached password and the access denied message will pop again.
Hope this helps.
Greetings

Authentication to host 'localhost' for user 'root' using method 'mysql_native_password' failed with message: Unknown database 'xxx'

I am using code first approach in my project. But when i am trying to run db-migrations by using 'update-database' command i am getting null reference exception and when I am running the application I am getting the following configuration error:
Authentication to host 'localhost' for user 'root' using method 'mysql_native_password' failed with message: Unknown database 'xxx'.
Here is the connection string:
<add name="DefaultConnectionString" connectionString="server=localhost;port=3306;Database=cps;uid=root;pwd=root;" providerName="MySql.Data.MySqlClient" />
P.S: It's running fine on the other system.
Your connection string is demanding a MySQL database called cps. It seems likely you have not yet created that database on your local MySQL server.
Pro tip: Always read error message text carefully, asking yourself "what could this mean?"
The solution I got for below error.
Authentication to host 'localhost' for user 'root' using method 'mysql_native_password' failed with message: Access denied for user 'root'#'localhost' (using password: YES)
<add name="constring" connectionString="Server=localhost;Uid=root;Database=databasename;Port=3306;" providerName="MySql.Data.MySqlClient"/>
=> Just remove the password
=> If you have 2 local servers with a different port number, just add it or else by default it will take 3306
Authentication to host 'localhost' for user 'root' using method 'mysql_native_password' failed with message: Access denied for user 'root'#'localhost' (using password: YES)
from
public string strconn = "SERVER = localhost ;DATABASE=restaurant;UID = root;pwd=12345678;convert zero datetime=True";
become
public string strconn = "SERVER =127.0.0.1 ;DATABASE=restaurant;UID = root;pwd=12345678;convert zero datetime=True";
fix localhost to 127.0.0.1 in connectionstring
Thanks for all the answers, But in my case as #GirishBabuC said its port and need to append the port in connection string in case you are using other then default port.
<add name="constring" connectionString="Server=localhost;Uid=root;Database=databasename;Port=3307;" providerName="MySql.Data.MySqlClient"/>
in my case its 3307.
while installing its asks for port.
This issue could come up depending on which version of MySQL is being targeted. You are welcome to try this solution to see if it works for you. Instead of using the Uid=*;Pwd=*; format, make use of the user=*;password=*; format.
Original Connection String:
Server=localhost;Port=3306;Database=databasename;Uid=sqltracking;Pwd=sqltracking;
One that works
server=localhost;port=3306;database=databasename;user=sqltracking;password=sqltracking;
The first method works on MySql 8, but not on MySql 5.
I haven't dug into the documentation behind these connection string configurations, however, I have noticed a difference between MySQL 5.7 and 8.0 in certain conditions. Although admittedly haven't spent a lot of time to figure out why it happens sometimes.
Also, remember to do a FLUSH PRIVILEGES on your MySQL instance after making any permission changes. This could have an effect as well.