Skip to content

Latest commit

 

History

History
87 lines (61 loc) · 3.89 KB

mariadb.md

File metadata and controls

87 lines (61 loc) · 3.89 KB

MariaDB

MariaDB is a community-developed fork of the MySQL relational database management system intended to remain free under the GNU GPL. Being a fork of a leading open source software system, it is notable for being led by the original developers of MySQL, who forked it due to concerns over its acquisition by Oracle.

Setup

Installation

🧑‍🎓 Guide Setup - DigitalOcean

Ubuntu/Debian

apt-get install mariadb-server

Configuration

Configuration File

⚙️ MariaDB Configuration File : The configuration file is where the MariaDB server reads its settings.

🗃️ List of options of the Config File

Location depends on the system, but it is usually located at /etc/mysql/my.cnf. For MariaDB server, the configuration file is /etc/mysql/mariadb.conf.d/50-server.cnf.

Configuration Options
  • datadir : The directory where MariaDB stores its data.
  • pid-file : The file where the server writes the process ID.
  • socket : The Unix socket file that the server uses for communication with local clients.
  • user : The MariaDB user that the server runs as.
  • port : The port number on which the server listens for TCP/IP connections.
  • bind-address : The IP address to bind to.
Example
[mysqld]
datadir=/var/lib/mysql
socket=/run/mysql/mysql.sock
pid-file=/run/mysql/mysql.pid
user=root
port=3306 # Default port
bind-address= 0.0.0.0 # Listen to all interfaces

Configuration of Database

Setup the database with user and password.

-- Create database
CREATE DATABASE IF NOT EXISTS <database>;
-- Create user and grant privileges
CREATE USER IF NOT EXISTS '<user>'@'<host>' IDENTIFIED BY '<password>';
GRANT ALL PRIVILEGES ON <database>.* TO '<user>'@'<host>' IDENTIFIED BY '<password>';
-- Change password of a user
ALTER USER '<root_user>'@'<host>' IDENTIFIED BY '<root_password>';
-- Flush privileges
FLUSH PRIVILEGES;

Usage

Command to Access Database

docker exec -it <container> mysql -u <user> -p <database>

or

mysql -u <user> -p <database>

Exit the database with exit command.