sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

Use mysql sqlx to report errors

Open liunn123 opened this issue 3 years ago • 4 comments

Bug Description

A clear and concise description of what the bug is.

Minimal Reproduction

A small code snippet or a link to a Github repo or Gist, with instructions on reproducing the bug.

Info

  • SQLx version: [0.6.0]
  • SQLx features enabled: [REQUIRED]
  • Database server and version: [REQUIRED] (MySQL<5.7.20>)
  • Operating system: [centos7.5]
  • rustc --version: [rustc 1.65.0-nightly (fa6ee9375 2022-09-12)]

[package] name = "rustTest" version = "0.1.0" edition = "2021" [dependencies] actix-rt="2.7.0" actix-web="4.1.0" dotenv = "0.15.0" chrono = {version = "0.4.19", features = ["serde"]} serde = {version = "1.0.140", features = ["derive"]} sqlx = {version = "0.6.0", default_features = false, features = [ "mysql", "runtime-tokio-rustls", "macros", "chrono", ]}

image

Use mysql sqlx to report errors

image

image

But PostgreSQL is correct

liunn123 avatar Sep 15 '22 02:09 liunn123

我自己使用 MySQL 没问题,建议:

  1. 检查一下 .env 中的 DATABASE_URL 与代码中的是否一致;
  2. 数据库是不是没弄好?~可先执行 sqlx database reset 重置数据库试试;~
  3. 再不行,切换 MySQL 版本看看。

此外,最好直接从 .env 中读取 DATABASE_URL 连接数据库;把 SQL 写入单独的脚本,然后用 sqlx::query_file_as! 之类的来加载,主要是便于使用专门的 SQL 编辑器编辑脚本。

arniu avatar Sep 16 '22 16:09 arniu

Also try switching from runtime-tokio-rustls to runtime-tokio-native-tls

abonander avatar Sep 16 '22 20:09 abonander

我自己使用 MySQL 没问题,建议:

  1. 检查一下 .env 中的 DATABASE_URL 与代码中的是否一致;
  2. 数据库是不是没弄好?~可先执行 sqlx database reset 重置数据库试试;~
  3. 再不行,切换 MySQL 版本看看。

此外,最好直接从 .env 中读取 DATABASE_URL 连接数据库;把 SQL 写入单独的脚本,然后用 sqlx::query_file_as! 之类的来加载,主要是便于使用专门的 SQL 编辑器编辑脚本。

恩,连接信息没有问题,我在数据库连接那里加上去这个就好了 ?ssl-mode=disabled" 但是我用的是5.7.20。
我笔记本5.5版本这种低版本还是不行,我感觉和版本有关

liunn123 avatar Sep 17 '22 02:09 liunn123

也尝试从切换runtime-tokio-rustlsruntime-tokio-native-tls

I will add this to the database connection ?ssl-mode=disabled" But I used 5.7.20.

The lower version of my laptop version 5.5 is still not good. I think it is related to the version

liunn123 avatar Sep 17 '22 02:09 liunn123