Use mysql sqlx to report errors
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", ]}

Use mysql sqlx to report errors


But PostgreSQL is correct
我自己使用 MySQL 没问题,建议:
- 检查一下
.env中的DATABASE_URL与代码中的是否一致; - 数据库是不是没弄好?~可先执行
sqlx database reset重置数据库试试;~ - 再不行,切换 MySQL 版本看看。
此外,最好直接从 .env 中读取 DATABASE_URL 连接数据库;把 SQL 写入单独的脚本,然后用 sqlx::query_file_as! 之类的来加载,主要是便于使用专门的 SQL 编辑器编辑脚本。
Also try switching from runtime-tokio-rustls to runtime-tokio-native-tls
我自己使用 MySQL 没问题,建议:
- 检查一下
.env中的DATABASE_URL与代码中的是否一致;- 数据库是不是没弄好?~可先执行
sqlx database reset重置数据库试试;~- 再不行,切换 MySQL 版本看看。
此外,最好直接从
.env中读取DATABASE_URL连接数据库;把 SQL 写入单独的脚本,然后用sqlx::query_file_as!之类的来加载,主要是便于使用专门的 SQL 编辑器编辑脚本。
恩,连接信息没有问题,我在数据库连接那里加上去这个就好了 ?ssl-mode=disabled"
但是我用的是5.7.20。
我笔记本5.5版本这种低版本还是不行,我感觉和版本有关
也尝试从切换
runtime-tokio-rustls到runtime-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