...
Code Block | ||
---|---|---|
| ||
var mysql = require('mysql') var connection = mysql.createConnection({ host: 'localhost', user: 'dbuserroot', password: 's3kreee7ppp', database: 'my_db'db_grad_cs_1917' }); con.connect(function(err) { if (err) throw err; console.log("Connected!"); }); |
We are running MySQL from a Docker container, the container can be started using the following command
...
parameter | meaning |
---|---|
-p 3307:3306 | bind the container port 3306 to host port 3307 |
--name mysql-populated | the runtime name of the container, can be used instead of image id |
-e | an environment variable to be passed into the container |
mysql-db-populated:latest | the actual image name, can be found using docker images |
Info |
---|
When you run the above script it fails with an error indicating that password authorisation is not supported. You need to change the MySQL plugin from auth_socket to mysql_native_password. Follow these steps For DockerCheck the IP address of the container that is hosting MySQL. Add this IP address to the MySQL users table for root user |
...
Info |
---|
Be sure to give the user for the new IP the correct rights |
...
Info |
---|
Now modify the privileges table |
Code Block | ||
---|---|---|
| ||
UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE User = 'root';
FLUSH PRIVILEGES; |
Info |
---|
Be sure to restart the MySQL server |