vapor/fluent-mysql-driver

Fatal error: Error raised at top level: ⚠️ MySQL Error: Unsupported auth plugin: caching_sha2_password

TofPlay opened this issue · 7 comments

Hi,
I just change my database to MySQL and when I run my app Xcode stop and display this error:
image
My package.swit:

// swift-tools-version:4.0
import PackageDescription

let package = Package(
    name: "MyApp",
    dependencies: [
        .package(url: "https://github.com/vapor/vapor.git", from: "3.0.0"),
        .package(url: "https://github.com/vapor/fluent-mysql.git", from: "3.0.0-rc"),
    ],
    targets: [
        .target(name: "App", dependencies: ["FluentMySQL", "Vapor"]),
        .target(name: "Run", dependencies: ["App"]),
        .testTarget(name: "AppTests", dependencies: ["App"])
    ]
)

MySQL launched with Docker:

docker run --name mysql -e MYSQL_USER=vapor  -e MYSQL_PASSWORD=password -e MYSQL_DATABASE=vapor  -p 3306:3306 -d mysql/mysql-server
0xTim commented

@TofPlay it's a bug in Vapor's MySQL due to a breaking change in MySQL 10.something. For now you can do

docker stop mysql
docker rm mysql
docker run --name mysql -e MYSQL_USER=vapor  -e MYSQL_PASSWORD=password -e MYSQL_DATABASE=vapor  -p 3306:3306 -d mysql/mysql-server:5.7

The underlying issue is raised at vapor/mysql-kit#172

Ok thanks @0xTim 🙂

vapor/mysql-kit#172 has been closed. This will be fixed as a part of the 3.0.0 tag.

This is fixed in 3.0.0? I'm still seeing this issue.....

This error is still persisting for me when starting a new project with Vapor 3.1.10 and attempting to configure FluentMySQL.

vapor/mysql-kit#172 seems like the related issue but I'm unsure if it was resolved. Additional clarification would be most appreciated.

We're also facing this using MySQL 5.7. We connect to MySQL via sidecar proxy which handles authentication for us, so we can't easily just add a password.

I also had this problem, but with some research on the net I managed to solve

Solution:

I'm using Xcode Version 11.3.1 and mySql: mysql 8.0.19 and Vapor 3.1.10

let mysqlConfig = MySQLDatabaseConfig( hostname: "127.0.0.1", port: 3306, username: "root", password: "****", database: "chatter", transport: MySQLTransportConfig.unverifiedTLS )

let mysql = MySQLDatabase(config: mysqlConfig)

OBS: this setting can differentiate. e.g: database, password(change in mysql)

and hostname: "127.0.0.1",
port: 3306,
username: "root",

in the class MySQLDatabaseConfig you can see if these are the information
public static func root(database: String) -> MySQLDatabaseConfig { return .init(hostname: "127.0.0.1", port: 3306, username: "root", database: database) }

Hope this helps.