Install MariaDB on Ubuntu

Task: Install mariaDB server on Ubuntu

Implementation:

  1. Update packages:
    sudo apt update
    sudo apt upgrade
  2. Install MariaDB server package:
    sudo apt install mariadb-server
  3. Check status of service:
    sudo systemctl status mariadb
  4. Check version:
    mysql -V
  5. Test it working:
    sudo mysql


Modify current root user access (recreate it):

sudo mysql -u root
mysql> SELECT User,Host FROM mysql.user;
mysql> DROP USER 'root'@'localhost';
mysql> CREATE USER 'root'@'%' IDENTIFIED BY '';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;

Create database and some another user:

mysql -u root -p
mysql> create database testdb;
mysql> grant all privileges on testdb.* to someuser@127.0.0.1 identified by 'somepass' with grant option;
mysql> grant all privileges on testdb.* to someuser@localhost identified by 'somepass' with grant option;
mysql> grant all privileges on testdb.* to someuser@'%' identified by 'somepass' with grant option;

Test it:
mysql --user=someuser --password=somepass --database=testdb

Done.

Leave a Reply

Your email address will not be published. Required fields are marked *




Enter Captcha Here :