์ผ๋ฌด์ง๊ฒ ์ค์นํ๊ณ Nodejs์ ์ฐ๋ํ๋ ค๊ณ ํ๋๊น ๋ฐ๋ก ๋ ์๋ฌ๊ฐ ๋์ค๋ค์...๐ญ๐ญ๐ญ๐ญ๐
1. ์ํ ์ฝ๋
์ฌ์ฉํ ์ฝ๋๋ ์๋์ ๊ฐ์ต๋๋ค. (์์ ๋งํฌ)
// test-mysql.js ํ์ผ
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'host-IP',
user : 'root',
password : 'Xptmxm1212!@',
database : 'my-Database'
});
connection.connect();
connection.query('select * from sample_table', function (error, results, fields) {
if (error){
console.log(error);
}
console.log(results);
});
connection.end();
2. ์๋ฌ ๋ด์ฉ
code: 'ER_NOT_SUPPORTED_AUTH_MODE',
errno: 1251,
sqlMessage: 'Client does not support authentication protocol requested by server; consider upgrading MySQL client',
Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
at Handshake.Sequence._packetToError (/dir/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
at Handshake.ErrorPacket (dir/node_modules/mysql/lib/protocol/sequences/Handshake.js:123:18)
at Protocol._parsePacket (dir/node_modules/mysql/lib/protocol/Protocol.js:291:23)
at Parser._parsePacket (dir/node_modules/mysql/lib/protocol/Parser.js:433:10)
at Parser.write (dir/node_modules/mysql/lib/protocol/Parser.js:43:10)
at Protocol.write (dir/node_modules/mysql/lib/protocol/Protocol.js:38:16)
at Socket.<anonymous> (dir/node_modules/mysql/lib/Connection.js:88:28)
at Socket.<anonymous> (dir/node_modules/mysql/lib/Connection.js:526:10)
at Socket.emit (events.js:315:20)
at addChunk (internal/streams/readable.js:309:12)
--------------------
at Protocol._enqueue (dir/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at Protocol.handshake (dir/node_modules/mysql/lib/protocol/Protocol.js:51:23)
at Connection.connect (dir/node_modules/mysql/lib/Connection.js:116:18)
at Object.<anonymous> (dir/nodejs/mysql.js:9:12)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 {
code: 'ER_NOT_SUPPORTED_AUTH_MODE',
errno: 1251,
sqlMessage: 'Client does not support authentication protocol requested by server; consider upgrading MySQL client',
sqlState: '08004',
fatal: true
}
3. ํด๊ฒฐ ๋ฐฉ๋ฒ
์ด ๋ฌธ์ ๋ ํด๋ผ์ด์ธํธ ํ๋ก๊ทธ๋จ์์ mysql ํจ์ค์๋ ํ๋ฌ๊ทธ์ธ "caching_sha2_password"์ ์ํํ์ง ๋ชปํด์ ์๊ธฐ๋ ์ค๋ฅ์
๋๋ค.
ํด๋ผ์ด์ธํธ ํ๋ก๊ทธ๋จ์์ ์ฌ์ฉํ ์ ์๋๋ก ์ ์ ์ ํจ์ค์๋ Plusin์ ๋ฐ๊ฟ์ค์๋ค.
mysql์ ์ ์ํ์๊ณ , ์๋์ ๊ฐ์ด ์์ ํฉ๋๋ค.
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Xptmxm1212!@';
์์ ์ด ์๋ฃ ๋์๋ค๋ฉด, ์๋ ์ฌ์ง๊ณผ ๊ฐ์ด Plugin์ด ๋ณ๊ฒฝ๋์์๊ฑฐ์์ :)
mysql> SELECT Host,User,plugin,authentication_string FROM mysql.user;
์ด์ , ์คํํ๋ฉด ์ ๋ ๊ฑฐ์์!! ๊ณ ๊ณ !!