MySQL Authentication Plugin Issues on macOS

I’m working on a blog project using Python and Flask, and I’m using the MySQL database from XAMPP for user registration. The project worked perfectly on my Windows machine, but after switching to macOS, I’ve been encountering various issues with the registration process. I’ve managed to resolve most of the issues, but I’m still struggling with one particular error. I’ve been working on this for a week now and could use some help.

Error Details:

MySQLdb.OperationalError: (2059, “Authentication plugin ‘mysql_native_password’ cannot be loaded: dlopen(/opt/homebrew/Cellar/mysql/9.0.1/lib/plugin/mysql_native_password.so, 0x0002): tried: ‘/opt/homebrew/Cellar/mysql/9.0.1/lib/plugin/mysql_native_password.so’ (no such file), ‘/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/mysql/9.0.1/lib/plugin/mysql_native_password.so’ (no such file), ‘/opt/homebrew/Cellar/mysql/9.0.1/lib/plugin/mysql_native_password.so’ (no such file)”)

enter image description here

Context:

•   The application is running on macOS using XAMPP.
•   The database is configured correctly, and I can connect to it using other tools.
•   I’ve tried various solutions like asking chatgpt or searching on google

Has anyone encountered this issue or have any suggestions on how to resolve it?

Thanks in advance for your help!

2

You need to install [email protected] or [email protected] on MacOS. Because native authentication plugin was removed from mysql 9.0

Run the command line below to uninstall [email protected]

  1. brew uninstall mysql

Run the command lines below to install [email protected]

  1. brew install [email protected]
  2. ln -s /opt/homebrew/opt/[email protected] /opt/homebrew/opt/mysql
  3. If you need to have mysql first in your PATH, run:
    echo 'export PATH="/opt/homebrew/opt/mysql/bin:$PATH"' >> ~/.zshrc

7

Downgrading to an insecure solution is not a good idea. There are good reasons for the old authentication hashing algorithm to be abandoned as can be found here.

A better solution is to upgrade the hashing algorithm to a more secure one. If setting up a database this should happen automatically. If upgrading from an earlier version there is a nice write-up here that explains how to temporarily disable authentication to allow manual upgrades of the password hashing algorithm.

Reproduction of the steps in the link:

  1. Disable the Grant Tables:

    Edit the MySQL configuration file, typically located at /etc/my.cnf.

    Add the following line under the [mysqld] section to disable the grant tables:

     [mysqld]
     skip-grant-tables
    
  2. Restart MySQL

  3. Connect to MySQL as the root user:

    mysql -u root

  4. Refresh the privileges:

    FLUSH PRIVILEGES;

  5. Check for users using the mysql_native_password plugin:

    SELECT User, Host, plugin FROM mysql.user WHERE plugin = 'mysql_native_password';
    
  6. Update the user(s) to use the caching_sha2_password plugin, e.g.:

    ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'new_password';
    
  7. Re-enable Grant Tables:

    After updating, remove or comment out the skip-grant-tables line from the MySQL configuration file.

  8. Restart MySQL to apply the changes

1

Mysql’s native authentication plugin was removed from mysql 9.0. You need to change the authentication plugin used for the users to one of the supported ones or downgrade mysql from the experimental 9.0 to a production 8.4 or 8.0 version.

9

Adding a solution specific to my situation. Installed MySQL by way of MAMP (cause it’s ‘easy’). Needed workbench specifically for the ERD generation. Workbench couldn’t connect to local mysql installed by mamp; other clients could connect.

MySQL installed by MAMP creates a root user using mysql_native_password plugin which is not supported anymore in MySQL 8.4.

Followed instructions here to change PWD storage for that same root user to sha2 cache:

https://php.watch/articles/fix-php-mysql-84-mysql_native_password-not-loaded

Relevant commands are:

  1. Check that it is in fact native password problem:

    SELECT user, host, plugin from mysql.user WHERE plugin=’mysql_native_password’;

  2. Change the user(s) to remove the need for native password plugin:

    ALTER USER ‘USERNAME’@’HOST’ IDENTIFIED WITH caching_sha2_password BY ‘NEW_PASSWORD’;

MySQL includes mysql_native_password plugin which implements Native Pluggable Authentication
This plugin is deprecated since v8.0 and it’s disabled by default in [email protected] but removed as of [email protected]

To fix this issue:

  1. Install [email protected]
    brew install [email protected]

  2. Start the server
    brew services start [email protected]

  3. Enable mysql_native_password in the configuration file

In my case config path is : /opt/homebrew/etc/my.cnf

sudo nano /opt/homebrew/etc/my.cnf

Your final file configuration should look like this:

# Default Homebrew MySQL server config
[mysqld]
mysql_native_password=ON                # Add this line <----
# Only allow connections from localhost
bind-address = 127.0.0.1
mysqlx-bind-address = 127.0.0.1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật