Issue
I use nodeJS
and npm package mysql
to read sql databases from the server. You know, the typical usage:
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'example.org',
user : 'bob',
password : 'secret'
});
//implicit connection and then query
connection.query('SELECT 1', function (error, results, fields) {
if (error) throw error;
console.log(results)
});
But now I need to run some tests locally on some virtual machines, and I want to read the data from a sql database stored as a .sql
file. This sql file was exported with phpmyadmin
How can I read from a sql database whose data is stored in the disk as a .sql file, said file exported via phpmyadmin?
Solution
You cannot use the file as a database. (Although that would be a cool project for somebody to create.)
The .sql file is just an export which contains actual sql statements one after another, which can be used to re-create a database by "importing".
My recommendation is to install mysql-server locally, import what you have, and connect to localhost 3306.
Answered By - andy magoon
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.