Skip to content

Latest commit

 

History

History
executable file
·
108 lines (68 loc) · 2.43 KB

mariadb-setup.md

File metadata and controls

executable file
·
108 lines (68 loc) · 2.43 KB

Setting up MariaDB

Disclaimer

This isn't a complete MariaDB tutorial, I just show minimum required things you need to do for using MariaDB with the bot.

You might want to look at other, more detailed guides.

Installing MariaDB

If you run the bot on an Ubuntu / Debian Linux machiene, you can install MariaDB like that:

sudo apt update
sudo apt install mariadb

If you use any other OS, please refer to the original MariaDB documentation

Then go through the complete installation process with the following command. The steps should be clearly understandable.

sudo mysql_secure_installation

Setting up privileges and creating the database

Open MariaDB as root:

sudo mysql -u root -p

Create the database:

CREATE DATABASE discordbot;

Make a new user for accessing the database:

CREATE USER '<username>'@'localhost' IDENTIFIED BY '<password>';

Grant privileges to that user:

GRANT ALL ON discordbot.* to '<username>'@'%' IDENTIFIED BY '<password>' WITH GRANT OPTION;

Flush privileges:

FLUSH PRIVILEGES;

Then exit:

quit;

(Optional) If you want to keep MariaDB running in the background event after a reboot, enable it's systemd service with:

sudo systemctl enable mariadb

Enbaling remote access to the database

This step is optional. If you only want to user your database on localhost, skip this part.

Open the following file with your preferred text editor:

sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf

Then enable remote access with modifying the bind-address = 127.0.0.1 line to bind-address = 0.0.0.0.

Restart MariaDB for the changes to take effect:

sudo systemctl restart mariadb

Importing an existing database

Again, this step is optional. If you've had a database before (and you've dumped it into an .sql file) here is how you can import it.

Note that you have to create the database before the import, if you've used mysqldump for backing up the database.

Select the discordbot database:

USE DISCORDBOT;

Import the data from the .sql file:

source /path/to/dump_file_name.sql

Conclusion

If you're done with the installation, then you're ready to create the tables (as explained in the original README file) and start using your databse.