• node连接mysql问题总结


    问题描述1

    2020-05-08 15:13:22,078 ERROR 20006 [ - 127.0.0.1 - 0ms GET / - ] nodejs.ER_BAD_DB_ERRORError: ER_BAD_DB_ERROR: Unknown database 'car_fe:web_performance'
        at Handshake.Sequence._packetToError (/Users/linjin/Desktop/web_performance/node_web_performance/server/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
        at Handshake.ErrorPacket (/Users/linjin/Desktop/web_performance/node_web_performance/server/node_modules/mysql/lib/protocol/sequences/Handshake.js:123:18)
        at Protocol._parsePacket (/Users/linjin/Desktop/web_performance/node_web_performance/server/node_modules/mysql/lib/protocol/Protocol.js:291:23)
        at Parser._parsePacket (/Users/linjin/Desktop/web_performance/node_web_performance/server/node_modules/mysql/lib/protocol/Parser.js:433:10)
        at Parser.write (/Users/linjin/Desktop/web_performance/node_web_performance/server/node_modules/mysql/lib/protocol/Parser.js:43:10)
        at Protocol.write (/Users/linjin/Desktop/web_performance/node_web_performance/server/node_modules/mysql/lib/protocol/Protocol.js:38:16)
        at Socket.<anonymous> (/Users/linjin/Desktop/web_performance/node_web_performance/server/node_modules/mysql/lib/Connection.js:88:28)
        at Socket.<anonymous> (/Users/linjin/Desktop/web_performance/node_web_performance/server/node_modules/mysql/lib/Connection.js:526:10)
        at Socket.emit (events.js:210:5)
        at addChunk (_stream_readable.js:309:12)
        --------------------
        at Protocol._enqueue (/Users/linjin/Desktop/web_performance/node_web_performance/server/node_modules/mysql/lib/protocol/Protocol.js:144:48)
        at Protocol.handshake (/Users/linjin/Desktop/web_performance/node_web_performance/server/node_modules/mysql/lib/protocol/Protocol.js:51:23)
        at PoolConnection.connect (/Users/linjin/Desktop/web_performance/node_web_performance/server/node_modules/mysql/lib/Connection.js:116:18)
        at Pool.getConnection (/Users/linjin/Desktop/web_performance/node_web_performance/server/node_modules/mysql/lib/Pool.js:48:16)
        at /Users/linjin/Desktop/web_performance/node_web_performance/server/node_modules/pify/index.js:29:7
        at new Promise (<anonymous>)
        at Pool.<anonymous> (/Users/linjin/Desktop/web_performance/node_web_performance/server/node_modules/pify/index.js:12:10)
        at Pool.ret [as getConnection] (/Users/linjin/Desktop/web_performance/node_web_performance/server/node_modules/pify/index.js:56:34)
        at Pool.query (/Users/linjin/Desktop/web_performance/node_web_performance/server/node_modules/mysql/lib/Pool.js:202:8)
        at /Users/linjin/Desktop/web_performance/node_web_performance/server/node_modules/pify/index.js:29:7
        sql: select now() as currentTime;
    code: "ER_BAD_DB_ERROR"
    errno: 1049
    sqlMessage: "Unknown database 'car_fe:web_performance'"
    sqlState: "42000"
    fatal: true
    name: "ER_BAD_DB_ERRORError"
    pid: 20006
    

    问题分析

    导致这个错误的原因是,目前,最新的mysql模块并未完全支持MySQL 8的“caching_sha2_password”加密方式,而“caching_sha2_password”在MySQL 8中是默认的加密方式。

    因此,下面的方式命令是默认已经使用了“caching_sha2_password”加密方式,该账号、密码无法在mysql模块中使用。

    解决方案

    cd /usr/local/mysql/lib/
    
    mysql
    
    ./mysql -uroot -p    
    
    1. 输入mysql密码

    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
    
    EXIT;
    

    问题描述2

    Mac OS zsh: command not found: mysql
    

    解决方案

    cd ~
    
    vim ~/.bashrc
    

    3.添加下面内容

    alias mysql=/usr/local/mysql/bin/mysql
    
    :wq
    
    source ~/.bashrc
    
  • 相关阅读:
    C# Large Files MD5 C# 获取大文件MD5
    C# SmtpClient 发邮件
    Windows Server 2008 R2 install Visual Studio 2015 failed
    C# 下载泛型数据
    SetApartmentState(ApartmentState state).Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process
    ADO.NET
    WPF DataGrid row background converter datagrid 行背景随绑定数据变化,转换器
    C# 截图ScreenCapture,保存
    打印发现function toUpperCase() { [native code] }
    正则匹配test
  • 原文地址:https://www.cnblogs.com/fe-linjin/p/12609378.html
Copyright © 2020-2023  润新知