10

I already use mariadb as a mysql server. However, I'm not sure using a node package designed for mysql is a good idea to use for mariadb.

There are actually two node packages:

I currently use mysql, since it seems pretty mature and maintained. It also seems to work well with mariadb on my side.

Are there any restrictions/incompatibilities/security issues to use mysqljs/mysql over mscdex/node-mariasql for a mariadb server?

Thanks

5 Answers 5

10

No, it doesn't matter which you use. MariaDB is backwards compatible with MySQL. You could even connect to MySQL with node-mariasql if you wanted.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. Taking a look at your package sources, I really like the idea to rely on the dynamic library (libmariadbclient). I may finally prefer node-mariasql.
2

Hi i am currently working on project with Maria DB and i am using node-mysql for production. It works really well for me. Reason of not using node-mariadb is the number of ratings and maturity of package.

Comments

2

I used mariasql in the past. It didn't cast fields to their proper JS type. Everything came back as a string (even integers). I'm going to try out the mysql driver. Seems weird that I have to use a different connection for each query if I want to do it in parallel. Seems like that should be abstracted for me.

Comments

2

Use this code my be helpfull for xampp mysql connection by using NodeJS

  var mysql      = require('mysql');
    var connection = mysql.createConnection({
      host     : 'localhost',
      user     : 'root',
      password : '',
      database : '<database name>'
    }); 
    connection.connect(function(err) {
        if (err) {
        console.error('error connecting: ' + err.stack);
        return;
    }
    else{
        console.log("database has been connected");
    }
    });
    var queryString = 'SELECT * FROM <table name>'; 
    connection.query(queryString, function(err, rows, fields) {
        if (err) throw err; 
        for (var i in rows) {
            console.log('filesname: ', rows[i].fieldname);
        }
    }); 
    connection.end();

1 Comment

Whilst this code snippet is welcome, and may provide some help, it would be greatly improved if it included an explanation of how and why this solves the problem. Remember that you are answering the question for readers in the future, not just the person asking now! Please edit your answer to add explanation, and give an indication of what limitations and assumptions apply.
1

My impression of node-mariasql is that it is immature in terms of supporting all database operations (especially prepared insert operations are lackluster atm) and also documentation is poor. I'd suggest using node-mysql for production applications.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.