MySQL with latest Vapor

I created a vapor project using SQLite which worked well. After making changes per your video for the use of MySQL, I get the following error when running the project:

"Thread 1: Fatal error: Error raised at top level: :warning: MySQL Error: Full authentication not supported over insecure connections.

  • id: MySQLError.fullAuthRequired

File: /Users/davidcutshaw/vapor/FutureView/.build/checkouts/mysql.git-1890032512239690518/Sources/MySQL/Connection/MySQLConnectionHandler.swift

  • func: handlePacket(ctx:packet:)
  • line: 52
  • column: 37

Here are some possible causes:

  • Using ‘caching_sha2_password’ auth plugin (default in MySQL >= 8.0.4) over an insecure (no SSL) connection."

I have not added any authentication to the project.
I am on MacOS X Version 10.13.5 (17F77) and Xcode Version 9.4.1 (9F2000) and I ran ‘vapor update’.

My package.swift looks like:

// swift-tools-version:4.0
import PackageDescription

let package = Package(
name: “FutureView”,
dependencies: [
// :droplet: A server-side Swift web framework.
.package(url: “https://github.com/vapor/vapor.git”, from: “3.0.0-rc”),

    // 🔵 Swift ORM (queries, models, relations, etc) built on SQLite 3.
    .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"])
]

)

My Dependencies:

image

The database is configured like so in config.swift:

var databases = DatabasesConfig()
let mysqlConfig = MySQLDatabaseConfig(hostname: “localhost”, port: 3306, username: “futureview”, password: “password”, database: “vapor”)
let database = MySQLDatabase(config: mysqlConfig)
databases.add(database: database, as: .mysql)
services.register(databases)

I used the following docker run command:

docker run --name mysql2 -e MYSQL_USER=futureview -e MYSQL_PASSWORD=password -e MYSQL_DATABASE=vapor -p 3306:3306 -d mysql/mysql-server

I’ve created many other projects using MySQL including your tutorial projects, but evidently not with this particular configuration. Thanks for any help with this error.

Yeah unfortunately MySQL 8 has broken a lot of things - basically it won’t work (easily) at the moment over HTTP. The fix is to change the Docker command to:

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