1
0
mirror of https://github.com/MinetestForFun/mysql_base.git synced 2024-12-26 09:40:20 +01:00
Minetest ? MySQL connector mod (requires LuaJIT FFI)
Go to file
dependabot-preview[bot] 049ffb18e5
Bump mysql from 4bc8277 to 720d2a3 (#1)
Bumps [mysql](https://github.com/luapower/mysql) from `4bc8277` to `720d2a3`.
- [Release notes](https://github.com/luapower/mysql/releases)
- [Commits](4bc8277470...720d2a3955)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
2020-08-19 17:00:27 -05:00
mysql@720d2a3955 Bump mysql from 4bc8277 to 720d2a3 (#1) 2020-08-19 17:00:27 -05:00
.gitmodules Initial commit 2017-06-03 22:58:42 -04:00
.luacheckrc Add Travis CI and LuaCheck (#2) 2020-05-06 13:58:07 -05:00
.travis.yml Add Travis CI and LuaCheck (#2) 2020-05-06 13:58:07 -05:00
abstraction.lua Improve a bit the code... 2019-09-26 16:44:19 -05:00
init.lua Add Travis CI and LuaCheck (#2) 2020-05-06 13:58:07 -05:00
LICENSE.txt Add LGPLv3 LICENSE.txt 2017-06-03 23:00:19 -04:00
mod.conf Improve a bit the code... 2019-09-26 16:44:19 -05:00
README.md Add Travis CI and LuaCheck (#2) 2020-05-06 13:58:07 -05:00

mysql_base

Build Status

Base Minetest mod to connect to a MySQL database. Used by other mods to read/write data.

Installing

Get this repository's contents using git, and make sure to fetch submodules (git submodule update --init).

Configuration

First, if mod security is enabled (secure.enable_security = true), this mod must be added as a trusted mod (in the secure.trusted_mods config entry). There is no other solution to make it work under mod security.

By default mysql_base doesn't run in singleplayer. This can be overriden by setting mysql_base.enable_singleplayer to true.

Configuration may be done as regular Minetest settings entries, or using a config file, allowing for more configuration options; to do so specify the path as mysql_base.cfgfile. This config must contain a Lua table that can be read by minetest.deserialize, i.e. a regular table definition follwing a return statement (see the example below).

When using flat Minetest configuation entries, all the following option names must be prefixed with mysql_base.. When using a config file, entries are to be hierarchised as per the dot separator.

Values written next to option names are default values.

Database connection

Minetest flat config file

Values after the "=" are the default values used if unspecified.

mysql_base.db.host = 'localhost'
mysql_base.db.user = nil -- MySQL connector defaults to current username
mysql_base.db.pass = nil -- Using password: NO
mysql_base.db.port = nil -- MySQL connector defaults to either 3306, or no port if using localhost/unix socket
mysql_base.db.db = nil -- <== Setting this is required

Lua table config file

Connection options are passed as a table through the db.connopts entry. Its format must be the same as LuaPower's MySQL module mysql.connect(options_t) function, that is (all members are optional);

return {
  db = {
    connopts = {
      host = ...,
      user = ...,
      pass = ...,
      db = ...,
      port = ...,
      unix_socket = ...,
      flags = { ... },
      options = { ... },
      attrs = { ... },
      -- Also key, cert, ca, cpath, cipher
    }
  }
}

Examples

Example 1

Using a Lua config file

minetest.conf:

mysql_auth.cfgfile = /srv/minetest/skyblock/mysql_auth_config

/srv/minetest/skyblock/mysql_auth_config:

return {
  db = {
    connopts = {
      user = 'minetest',
      pass = 'BQy77wK$Um6es3Bi($iZ*w3N',
      db = 'minetest'
    },
  }
}

Using only Minetest config entries

minetest.conf:

mysql_auth.db.user = minetest
mysql_auth.db.pass = BQy77wK$Um6es3Bi($iZ*w3N
mysql_auth.db.db = minetest

License

mysql_base is licensed under LGPLv3.

Using the Public Domain-licensed LuaPower mysql module.