php mysqli_connect: authentication method unknown to the client [caching_sha2_password]

前端 未结 11 2269
遥遥无期
遥遥无期 2020-11-22 03:40

I am using php mysqli_connect for login to a MySQL database (all on localhost)



        
11条回答
  •  梦毁少年i
    2020-11-22 04:04

    If you're on a Mac, here's how to fix it. This is after tons of trial and error. Hope this helps others..

    Debugging:

    $mysql --verbose --help | grep my.cnf
    
    $ which mysql
    /usr/local/bin/mysql
    

    Resolution: nano /usr/local/etc/my.cnf

    Add: default-authentication-plugin=mysql_native_password

    -------
    # Default Homebrew MySQL server config
    [mysqld]
    # Only allow connections from localhost
    bind-address = 127.0.0.1
    default-authentication-plugin=mysql_native_password
    ------
    

    Finally Run: brew services restart mysql

提交回复
热议问题