blackbeam / rust-mysql-simple

Mysql client library implemented in rust.
Apache License 2.0
652 stars 145 forks source link

invalid port number #343

Closed 5-23 closed 1 year ago

5-23 commented 1 year ago

I don't know why the error pops up code:

fn main() {
    let id = "root";
    let pw = "xx1121!!!!";
    let name = "name";

    let url = format!("mysql://{id}:{pw}@localhost:3306:{name}");
    println!("{:?}", url.trim());
    let pool = mysql::Pool::new(url.trim())
        .expect("fail");
}

terminal:

"mysql://root:xx1121!!!!@localhost:3306:name"
thread 'main' panicked at 'fail: UrlError { URL ParseError { invalid port number } }', src\main.rs:10:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\debug\rust.exe` (exit code: 101)