Authentication plugin error while connecting to MySQL database - mysql

I am working on macOS ver 10.13.5 - the newest one actually.
I usually work with Laravel projects (5.6), and so I am using brew services isntaller to make local enviroment working.
I am using PHP v 7.1.16, MySQL 8.0.11 and Valet in v. 2.0.12
PHP and MySQL installed through Brew.
I've been working without any problems for like 3 months in the past, but the day when I had to reinstall my os finally come.
After reinstalling macOS with the fresh copy, and installing each service in the same version as it's been before, I am getting some weird error while trying to connect to the MySQL database through SequelPro.
Here's some logs:
MySQL said: Authentication plugin 'caching_sha2_password' cannot be
loaded: dlopen(/usr/local/lib/plugin/caching_sha2_password.so, 2): image
not found
That's weird, as I've been working with the same stuff without any problems for quite a while...
So I'd appreciate any advices on how to deal with this problem.
Also I'd like to notice that I've read almost everything about this problem, but I wasn't able to find at least one with configuration like mine (most of them described this problem as while working with local database provided by mysql or some other services provider).

The error message appears because MySQL v8 changed the default authentication plugin / method, which has no backwards compatibility with older clients.
The error can be worked around by using the legacy authentication method, which can be enabled for the root user by doing the following:
After installing MySQL, authenticate using the CLI e.g
mysql -uroot
Then run the following command to use the old authentication method:
ALTER USER root#localhost IDENTIFIED WITH mysql_native_password BY 'PASSWORD';
Lastly, flush the privileges:
FLUSH PRIVILEGES;
Now you should able to connect using SequelPro again (using the specified password).

Related

MySql 8.0.15 install failure Invalid Server Template

This is my first MySql install from the ground up.
I am using Windows Server 2016, trying to install MySql 8.0.15. I am doing this to try and use it with php 7.3.1.
The install has all the listed prerequisites.
When I get the config section of mysql insstaller, it breaks on the first response with an error of "Beginning configuration step: Writing configuration file
Invalid server template
Ended configuration step: Writing configuration file"
The system event log has one error, "The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID
{8D8F4F83-3594-4F07-8369-FC3C3CAE4919}
and APPID
{F72671A9-012C-4725-9D2F-2A4D32D65169}
to the user NT AUTHORITY\SYSTEM SID (S-1-5-18) from address LocalHost (Using LRPC) running in the application container Unavailable SID (Unavailable). This security permission can be modified using the Component Services administrative tool."
But I'm not sure this is even the right troubleshooting path to start down.
Can you assist with some guidance?
I had the same problem with the
mysql-installer-web-community.
The mysql-installer-community was working without a problem.
The bottom link is the none web installer which was working.
For me initially when I was not accepting the initial update mysql pop-up then installer was not working, but once I accepted it. Then it successfully worked for me.
I have been able to install after getting the same error.
I have changed the credentials for the sql root.
By default, host is set to something like %ALL_HOST%. I changed to localhost.
I ended up uninstalling all mysql 8 components that had already installed.
Then went back and got the mysql installer 5.7.25.0. I think I had some trouble after that, but it wasn't the same error. I finally ended up installing mysql 8.0.15 by itself and it worked. Then I went back and did the connectors. Next the workbench. Finally docs and samples. Doing them one at a time seemed to go better. I am now up and running.
Here's what I did to fix the issue
completely removed mySQL Server and Workbench installations.
uninstalled the mySQL web installer. Restarted my computer.
ran the mySQL web installer again (only installing mySQL Server)
downloaded the mySQL Workbench installer to install Workbench separately

Sequel Pro and MySQL connection failed

I just installed mysql on mac from Homebrew
brew install mysql
mysql -V
mysql Ver 8.0.11 for osx10.13 on x86_64 (Homebrew)
from terminal it works and I can login to mysql but from Sequel Pro it says
Unable to connect to host 127.0.0.1, or the request timed out.
Be sure that the address is correct and that you have the necessary
privileges, or try increasing the connection timeout (currently 10
seconds).
MySQL said: Authentication plugin 'caching_sha2_password' cannot be
loaded: dlopen(/usr/local/lib/plugin/caching_sha2_password.so, 2):
image not found
can't figure out what I am missing
This is because Sequel Pro is not ready yet for a new kind of user login, as the error states: there is no driver.
mysql + homebrew
Basically you will have to perform some actions manually, however- your database data won't be deleted like in solution below
Go to my.cnf file and in section [mysqld] add line:
default-authentication-plugin=mysql_native_password
Login to mysql server from terminal: run mysql -u root -p, then inside shell execute this command (replacing [password] with your actual password):
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY '[password]';
exit from mysql shell with exit and run brew services restart mysql.
Should work.
Quick fix (destructive method)
Quick fix for non-homebrew installs:
Apple Logo > System Preferences > MySQL > Initialize Database, then type your new password and select 'Use legacy password'
After restart you should be able to connect. Do it only on fresh installs, because you may lost your db tables otherwise.
my.cnf
The my.cnf file is located in /etc/my.cnf on Unix/Linux
Alternatives
For those who is still struggling with Sequel Pro problems: Sequel Pro was a great product, but with tons of unresolved issues and last release being dated to 2016 perhaps it's a good idea to look for some alternatives. There is a fork of SequelPro called SequelAce that seems to be pretty stable and up-to-date, it keeps similar functionality, similar look and feel, yet at the same time it is devoid of old Sequel Pro problems
TL;DR: Sequel Pro is dead since 2016. Don't downgrade your DB because of a tool. Move on to an alternative tool.
Update 2020: Sequel Pro is officially dead but unofficially alive! You can find the "nightly" builds that don't have this issue (i.e. support Mysql 8 auth) in here: https://sequelpro.com/test-builds
Update 2021: Sequel Ace is a good similar alive alternative: https://github.com/Sequel-Ace/Sequel-Ace#installation (Credits to Maciej Kwas's answer)
All the other solutions here are recommending changing your DB settings (making it less secure, as advertised by MySQL) for the tool you are using. That's not acceptable to me.
I have always been a huge fan of Sequel Pro, even donated to it. But, with all my passion and love, I am sorry if the tool doesn't have any release since 2016. YOLO, and I need to move on!
The alternative I found (from https://stackoverflow.com/a/55235533/2321594, thanks to #arcseldon) is DBeaver which supports MySQL 8's new authentication (non-legacy) method.
PS. The only trick in the tool side, not the DB side is when you are creating a MySQL 8 connection you might need to go to "Driver Properties" (later can be found in Edit Connection) and turn the value of allowPublicKeyRetrieval to true.
I needed this to connect to my MySQL container created using Docker. To have the IP of MySQL be visible to the outside, for any other application in your ecosystem (not just this tool), you should either create a new user in MySQL, or pass -e MYSQL_ROOT_HOST=% in the run-time or as an ENV.
Assuming you don't have a mysql configuration, echo the following to ~/.my.conf
[mysqld]
default-authentication-plugin=mysql_native_password
Sign into mysql with mysql -u root -p
Set the root user password with ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY '[PASSWORD]'; where [PASSWORD] is a password of your choosing.
Restart mysql with e.g. brew services restart mysql
Sequel Pro is officially dead and no longer supports newer MySql features. However, the good news is that it was replaced by Sequel Ace which is available on GitHub and App store. The app is free of charge and looks like official replacement for Sequel Pro as the post was made by one of the collaborators of Sequel Pro.
Ps. I decided to post this as an answer as others have not mentioned that there is now an up-to-date replacement for Sequel Pro
If you connect to MySQL via root#127.0.0.1, make sure that you reset its password too!
ALTER USER 'root'#'127.0.0.1' IDENTIFIED WITH mysql_native_password BY '[password]';
It's working for me. if you are getting this error :
Unable to connect to host 127.0.0.1, or the request timed out.
Be sure that the address is correct and that you have the necessary
privileges, or try increasing the connection timeout (currently 10
seconds).
MySQL said: Authentication plugin 'caching_sha2_password' cannot be
loaded: dlopen(/usr/local/lib/plugin/caching_sha2_password.so, 2):
Plz try this solution
If anyone facing this issue and installed MySQL version > 8 through .dmg file; downloaded it from the official link. In that case please use this guideline. I am adding the same details below in case the link will not be available in the future.
This issue is because you're using the new Strong Password Encryption which is a new feature in MySQL 8, if you installed MySQL 8 using the .dmg file, you can go to System Preferences > MySQL and then click on Initialize Database type your password and select the second option Use Legacy Password Encryption.

MySQL 8.0.11 error connecting due to caching_sha2_password

When I try to connect to server on MySQL Workbench, I get the error saying
Your connection attempt failed to user 'root' from your host to server as localhost:3306:
Authentication plugin caching_sha2_password cannot be loaded:
The specified module could not be found.
It seems like I do not have the module for caching_sha2_password installed. How do I install this plugin?
I tried to follow steps provided here. But this is my first interaction with MySQL, so I did not understand the steps.
For example, under Using SHA-2 Pluggable Authentication, it says
"storing those values in the plugin and authentication_string columns of the > mysql.user system table."
But where is the mysql.user system table and how do I access it and store the values?
Any help would be greatly appreciated!
You are looking at the wrong places. The story is this:
MySQL 8 introduced a new authentication method: caching_sha2_password which improves performance (hence the caching) for a secure authentication (the sha2 hashing). This breaking change had been made the default for new accounts pretty late so that MySQL Workbench (and quite a number of other client tools) could not be made ready for it when MySQL 8.0.11 was released. Unprepared client applications/libraries will show the mentioned error.
Many of the socalled "solutions" simply recommend to switch the authentication method to the older, less secure one (MySQL native). This is rather a hack than a solution. And keep in mind this only applies to new accounts which by default use the new auth method. Existing accounts (e.g. when you upgrade an older server to 8.0) still work as before, unless you explicitly changed the user's auth method.
Meanwhile MySQL Workbench catched up here and there's a release candidate (MySQL Workbench 8.0.11 RC) available on the MySQL download page (see the "Development Releases" tab). Use that for your 8.x server. A GA version will follow soon.

MySQL 8.0.11 error connect to caching_sha2_password the specified module could not be found

I've tried to connect to the latest MySQL server 8.0.11 from MySQL workbench, but the error keeps popping up: Cannot connect to MySQL server, authentication plugin: caching_sha2_password: the specified module could not be found.
I tried looking at MySQL server installation videos online and replicated every step accurately, but the error persists.
Any help is greatly appreciated.
I had the following solution:
change my.ini in a [mysqld] section like this:
#default_authentication_plugin=caching_sha2_password (comment line!)
default_authentication_plugin=mysql_native_password (new line)
Connect to your MySQL under root in a command line client
and execute:
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'xxx';
Where xxx is your current password.
Try to connect your MySQL use terminal, and use this.
mysql > ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'yourpassword';
See:
Changes in MySQL Workbench 8.0.11 (2018-04-19, Release
Candidate)
...
MySQL Workbench now supports the caching_sha2_password authentication plugin introduced in MySQL 8.0 (see Caching SHA-2 Pluggable Authentication). A user account can be reset to use the other available authentication types for making a connection.
...
After poking around I actually found a way to solve it:
During the configuration, when you reach the authentication method choose the Legacy Authentication Method.
It worked for me~!
I was seeing this issue with HeidiSQL, and I found a workaround in the HeidiSQL Github repository:
https://github.com/HeidiSQL/HeidiSQL/issues/163
I fixed by copying libmysql.dll from my last MySql install to my HeidiSQL folder.
If you have just installed mysql server. Run the installer again and it will allow you to reconfigure the options.
On the third sceen it will say
"Use legacy Authentication method"
choose that option
I know it is an old post. This is just to share my experience, hoping it will be useful for someone.
I also faced similar issue.
We can use the portable version of Heidisql. The portable version does not have this issue.
using mysql_native_password is a workaround.
Your client software (MySQL Workbench) does not support the authentication plugin most probably because it is an older version.
https://tableplus.io/blog/2018/07/failed-to-load-caching-sha2-password-authentication-plugin-solved.html
follow the above link.
The actual reason for "caching_sha2_password" is because while installing MySQL under Authentication Method, by default Use Strong Crypted Password radio button is chosen, instead we need to give User Legacy Authentication type password option for password
Run this in MySQL WorkBench:
ALTER USER 'user'#'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
Then further edit the credential and schema to access under the below directory path:
ror_project_path/config/database.yml

Cannot connect Wordpress to MySQL database

Doing some local website work to learn Wordpress theme development.
Tried to set up Wordpress through the prompts, also tried it by manually entering information in the wp-config.php file, neither would work. Still cannot connect to the database, the setup-config.php page returns "Error establishing a database connection". I've double, triple, and quadruple checked the login credentials (database name, username, password etc.), they are complete and correct. Deleted wp-config.php and tried again through the web page, same result.
MySQL is definitely running, the Mac System Preferences panel says so, and I can login and run SQL queries at the command line, although I have to do that as root. Should I be running MySQL as root?
This problem exists with Wordpress and also with an instance of phpMyAdmin that I've also installed, so I don't think it's anything to do with the PHP code as such, it smells more like a permissions thing. For what it's worth, I've edited my httpd.conf file to get Wordpress on port 80 and phpMyAdmin on 8081. Apache is serving those sites up as it should and PHP is running, it's just getting either site to connect to the database that's the problem.
System information:
Mac OS X 10.9.5 (Mavericks)
PHP Version 5.4.30
MySQL version:
mysql Ver 14.12 Distrib 5.0.45, for apple-darwin9.2.0 (i686) using EditLine wrapper
In my case it was as simple as changing the DB_HOST so it was using the correct host and port in wp-config.php:
define('DB_HOST', '127.0.01:3306');
I found the solution on this stackoverflow page.
By default, Apache cannot send requests to a remote MySQL server. It should be enabled.
On CentOS 6 the solution is the command:
setsebool httpd_can_network_connect=1
Check your phpinfo(); to see if MySQL extension for php is installed.
I experienced a similar issue and it turned out that the authentication type used by MYSQL was not supported.
To verify this, add
define('WP_DEBUG', true)
in the wp-config.php and re-run the installation. You will see an entry indicating if that's the case.
If the issue is confirmed to the authentication method, try
mysql> CREATE USER ‘username’#‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘password’;
after logging in to mysql console.