MySqlJS.com

Access MySql from Javascript

Getting started

  • 1. Include the script:
    <script src="https://mysqljs.com/mysql.js">
    </script>
  • 2. Add a line of code:
    MySql.Execute(
        "mysql.yourhost.com", 
        "username", 
        "password", 
        "database", 
        "select * from Users", 
        function (data) {
            console.log(data)
    });
    

Security

Can't everyone see my database password?

Only if they can see your source code.

This service is designed for situations where the source code is not accessible to end users, such as Hybrid (cordova/Phonegap) apps, or WinJS based Windows Store apps - Or cases where your website is not for public use, and suitably password protected.

This service can also be used for prototyping purposes, so that you can get your front-end up and running without worrying about the middleware.

Getting started

Don't have access to a MySql database, use this one.

Host: sql8.freemysqlhosting.net
Database name: sql8173720
Database user: sql8173720
Database password: S4EsfUDHt7

These credentials are public to everyone, so don't put anything important in this database, and don't expect it to stay there, but feel free to play with it.

<html>
<head>
    <title>MySqlJs test</title>
</head>
<script src="https://mysqljs.com/mysql.js"></script>
<body>
<pre id="output"></pre>
<script>
    MySql.Execute(
        "sql8.freemysqlhosting.net",
        "sql8173720", 
        "S4EsfUDHt7", 
        "sql8173720", 
        "select * from Users", 
        function (data) {
        document.getElementById("output").innerHTML = JSON.stringify(data,null,2);
    });
</script>
</body>
</html>

It's free!

This is a free script, no usage restrictions. You can include it license free, in any project, either commercial or non commercial. But, if you really like it, then please consider buying our app SQL Mobile!