ER_NOT_SUPPORTED_AUTH_MODE - MySQL server

前端 未结 11 815
旧时难觅i
旧时难觅i 2020-12-02 10:22

I have setup a MySQL database. When I try to access it through my Node JS server, I am getting the error

\"ER_NOT_SUPPORTED_AUTH_MODE: Client does no

相关标签:
11条回答
  • 2020-12-02 11:02
    var connection = mysql.createConnection({
      host     : 'localhost',
      user     : 'root',
      password : '********',
      database : 'vod_bill_database',
      port : 3308 
    }); 
    

    I had the same error and since i changed my port in phpmyadmin from 3306 to 3308 therefore here also i had to write port: 3308 and it started working.

    0 讨论(0)
  • 2020-12-02 11:06

    try the older version of mysql like 5.6.40, it uses by default SHA256_password auth where new version 8.0. uses by default sha2_password auth which is more secure and throw this authentication protocol error. MYSQL installer 5.6.40

    0 讨论(0)
  • 2020-12-02 11:09

    just create a new user on MySQL

    CREATE USER 'foo'@'localhost' IDENTIFIED WITH mysql_native_password BY 'bar';
    
    0 讨论(0)
  • 2020-12-02 11:12

    1st run this code ->

    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
    

    2nd

    flush privileges;
    
    0 讨论(0)
  • 2020-12-02 11:12

    yellow yow bros !

    // mysql.ts
    const pool = mysql.createPool({
        connectionLimit: 10,
        host: "localhost",
        user: "root",
        password: "password",
        database: "rest-resume-api",
    });
    

    and then I have a docker-compose file such as

    # docker-compose.yml
    
    version: '3.3'
    
    services:
      db:
        image: mysql
        restart: always
        command: --default-authentication-plugin=mysql_native_password
        environment:
          MYSQL_DATABASE: 'rest-resume-api'
          MYSQL_USER: 'root'
          MYSQL_ROOT_PASSWORD: 'password'
        ports:
          - '3306:3306'
        expose:
          - '3306'
        volumes:
          - my-db:/var/lib/mysql2
    volumes:
      my-db:
    
    
    0 讨论(0)
  • 2020-12-02 11:22

    I figured that in some MySQL versions they have the authentication for the establishment of a connection a bit messed. All I had to do was add the line "insecureAuth : true" to my connection attempt.

    var connection = mysql.createConnection({
      host     : 'localhost',
      user     : 'root',
      password : '********',
      database : 'vod_bill_database',
      insecureAuth : true
    }); 
    

    It is working fine now.

    0 讨论(0)
提交回复
热议问题