-
-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Currently cannot support auth method mismatch! #128
Comments
Try running in your mysql instance this query: ALTER USER 'root'@'%' IDENTIFIED WITH caching_sha2_password BY 'your-root-password'; Basically there are two authentication strategies and this library supports the latest one. https://dev.mysql.com/doc/refman/8.0/en/caching-sha2-pluggable-authentication.html Perhaps while this gets fixed you could try using https://github.com/sail-sail/mysql2 that supports both. This is the one that is throwing the exception: ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'your-root-password'; |
I search the code and get the following result
it seems the driver can support mysql_native_password? @sant123 |
Interesting, I tested again and now is working: import { Client } from "https://deno.land/x/mysql@v2.10.2/mod.ts";
const client = await new Client().connect({
hostname: "127.0.0.1",
username: "root",
db: "mydb",
password: "set-your-password",
});
const users = await client.query(`select * from users`);
console.log(users); create schema mydb;
use mydb;
CREATE TABLE `users` (
`id` int NOT NULL AUTO_INCREMENT,
`nombre` varchar(45) NOT NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `mydb`.`users` (`nombre`) VALUES ('foo');
INSERT INTO `mydb`.`users` (`nombre`) VALUES ('bar');
INSERT INTO `mydb`.`users` (`nombre`) VALUES ('baz');
docker run -e "MYSQL_ROOT_PASSWORD=set-your-password" -p 3306:3306 -d mysql:8.0.28-oracle |
deno 1.28.1 (release, x86_64-unknown-linux-gnu) |
using mysql 8, for me works with this is actually aligned with:
steps to reproduce
docker run --name mysql -d \
-p 3306:3306 \
-e MYSQL_ROOT_PASSWORD=change-me --restart unless-stopped \
mysql:8
docker exec -it mysql bash
mysql -u root -p
ALTER USER 'root'@'%' IDENTIFIED WITH caching_sha2_password BY 'change-me';
import { Client } from "https://deno.land/x/mysql@v2.11.0/mod.ts";
export async function main() {
const mysql_conn = {
host: '0.0.0.0',
port: 3306,
user: 'root',
password: 'change-me',
database: 'mysql'
};
mysql_conn.db = mysql_conn.database;
mysql_conn.hostname = mysql_conn.host;
mysql_conn.username = mysql_conn.user;
const client = await new Client().connect(
mysql_conn,
);
return (await client.execute('SHOW TABLES'));
}
console.log(await main()) actual resultINFO connecting 0.0.0.0:3306
INFO close connection
Uncaught Error: Access denied for user 'root'@'172.17.0.1' (using password: YES)
at PoolConnection.nextPacket (https://deno.land/x/mysql@v2.11.0/src/connection.ts:216:13)
at async PoolConnection._connect (https://deno.land/x/mysql@v2.11.0/src/connection.ts:145:23)
at async PoolConnection.connect (https://deno.land/x/mysql@v2.11.0/src/connection.ts:179:5)
at async Client.createConnection (https://deno.land/x/mysql@v2.11.0/src/client.ts:47:5)
at async DeferredStack.creator (https://deno.land/x/mysql@v2.11.0/src/pool.ts:67:20)
at async DeferredStack.pop (https://deno.land/x/mysql@v2.11.0/src/deferred.ts:35:16)
at async ConnectionPool.pop (https://deno.land/x/mysql@v2.11.0/src/pool.ts:99:14)
at async Client.useConnection (https://deno.land/x/mysql@v2.11.0/src/client.ts:105:24)
at async Client.execute (https://deno.land/x/mysql@v2.11.0/src/client.ts:96:12)
at async main (<anonymous>:15:12) expectedit runs workaroundin mysql docker run ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'change-me'; and then re-run the script, it will not throw that error again |
I actually just realized that lack of support for
@manyuanrong are there any plans in nearest future to support it? |
@mrl5 The docs site is outdated. It was supported. I guess recent changes broke it😢. Trying fixing... |
deno 1.19.2
MySQL Community Server 8.0.28
https://deno.land/x/mysql@v2.10.2
https://deno.land/x/oak@v10.5.1/mod.ts
跑起来报错:
error: Uncaught (in promise) Error: Currently cannot support auth method mismatch!
throw new Error("Currently cannot support auth method mismatch!");
^
at PoolConnection._connect (https://deno.land/x/mysql@v2.10.2/src/connection.ts:104:17)
at async PoolConnection.connect (https://deno.land/x/mysql@v2.10.2/src/connection.ts:148:5)
at async Client.createConnection (https://deno.land/x/mysql@v2.10.2/src/client.ts:47:5)
at async DeferredStack.creator (https://deno.land/x/mysql@v2.10.2/src/pool.ts:61:20)
at async DeferredStack.pop (https://deno.land/x/mysql@v2.10.2/src/deferred.ts:35:16)
at async ConnectionPool.pop (https://deno.land/x/mysql@v2.10.2/src/pool.ts:93:14)
at async Client.useConnection (https://deno.land/x/mysql@v2.10.2/src/client.ts:105:24)
at async Client.execute (https://deno.land/x/mysql@v2.10.2/src/client.ts:96:12)
The text was updated successfully, but these errors were encountered: