Bitnami MariaDB Installer

NOTE: Before running the commands shown on this page, you should load the Bitnami stack environment by executing the installdir/use_APPNAME script (Linux and Mac OS X) or by clicking the shortcut in the Start Menu under "Start -> Bitnami APPNAME Stack -> Application console" (Windows). Learn more.
NOTE: When running the commands shown on this page, replace the installdir placeholder with the full installation directory for your Bitnami stack.

Description

MariaDB is an open source, community-developed SQL database server that is widely in use around the world due to its enterprise features, flexibility, and collaboration with leading tech firms.

First steps with the Bitnami MariaDB Stack

Welcome to your new Bitnami application! Here are a few questions (and answers!) you might need when first starting with your application.

What are the system requirements?

Before you download and install your application, check that your system meets these requirements.

How do I install the Bitnami MariaDB Stack?

Windows, OS X and Linux installer
  • Download the executable file for the Bitnami MariaDB Stack from the Bitnami website.

  • Run the downloaded file:

    • On Linux, give the installer executable permissions and run the installation file in the console.
    • On other platforms, double-click the installer and follow the instructions shown.

Check the FAQ for instructions on how to download and install a Bitnami Stack for more details.

The application will be installed to the following default directories:

Operating System Directory
Windows C:\Bitnami\APPNAME-VERSION
Mac OS X /Applications/APPNAME-VERSION
Linux /opt/APPNAME-VERSION (running as root user)
OS X VM
  • Download the OS X VM file for the Bitnami MariaDB Stack from the Bitnami website.
  • Begin the installation process by double-clicking the image file and dragging the WordPress OS X VM icon to the Applications folder.
  • Launch the VM by double-clicking the icon in the Applications folder.

What credentials do I need?

You need application credentials, consisting of a password. This will allow you to log in to the services of the Bitnami stack.

What is the administrator password?

  • For Windows, Linux and OS X installers, the password was configured by you when you first installed the application.
  • For OS X VMs, the password can be obtained by clicking the Bitnami badge at the bottom right corner of the application welcome page.

How to start or stop the services?

Linux

Bitnami native installers include a graphical tool to manage services. This tool is named manager-linux-x64.run on Linux and is located in the installation directory. To use this tool, double-click the file and then use the graphical interface to start, stop or restart services. Server log messages can be checked in the "Server Events" tab.

Management tool

The native installer also includes a command-line script to start, stop and restart applications, named ctlscript.sh. This script can be found in the installation directory and accepts the options start, stop, restart, and status. To use it, log in to the server console and execute it following the examples below:

  • Call it without any service names to start all services:

      $ sudo installdir/ctlscript.sh start
    
  • Use it to restart a specific service only by passing the service name as argument - for example, mysql, postgresql or apache:

      $ sudo installdir/ctlscript.sh restart mysql
      $ sudo installdir/ctlscript.sh restart postgresql
      $ sudo installdir/ctlscript.sh restart apache
    
  • Obtain current status of all services:

      $ installdir/ctlscript.sh status
    

The list of available services varies depending on the required components for each application.

Mac OS X

Bitnami native installers include a graphical tool to manage services. This tool is named manager-osx on Mac OS X and is located in the installation directory. To use this tool, double-click the file and then use the graphical interface to start, stop or restart services. Server log messages can be checked in the "Server Events" tab.

Management tool

The native installer also includes a command-line script to start, stop and restart applications, named ctlscript.sh. This script can be found in the installation directory and accepts the options start, stop, restart, and status. To use it, log in to the server console and execute it following the examples below:

  • Call it without any service names to start all services:

    $ sudo installdir/ctlscript.sh start
    
  • Use it to restart a specific service only by passing the service name as argument - for example, mysql or apache:

     $ sudo installdir/ctlscript.sh restart mysql
     $ sudo installdir/ctlscript.sh restart apache
    
  • Obtain current status of all services:

     $ installdir/ctlscript.sh status
    

The list of available services varies depending on the required components for each application.

NOTE: If you are using the stack manager for Mac OS X-VM, please check the following blog post to learn how to manage services from its graphical tool.

Windows

Bitnami native installers include a graphical tool to manage services. This tool is named manager-windows.exe on Windows and is located in the installation directory. To use this tool, double-click the file and then use the graphical interface to start, stop or restart services. Server log messages can be checked in the "Server Events" tab.

Management tool

The Windows native installer creates shortcuts to start and stop services created in the Start Menu, under "Programs -> Bitnami APPNAME Stack -> Bitnami Service". Servers can also be managed from the Windows "Services" control panel. Services are named using the format APPNAMESERVICENAME, where APPNAME is a placeholder for the application name and SERVICENAME is a placeholder for the service name. For example, the native installer for the Bitnami WordPress Stack installs services named wordpressApache and wordpressMySQL.

These services will be automatically started during boot. To modify this behaviour, refer to the section on disabling services on Windows.

What is the default configuration?

The grant tables define the initial MariaDB user accounts and their access privileges. The default configuration consists of:

  • A privileged account with a username of root. The root user has remote access to the database.
  • An anonymous user without remote access to the database server. This user can only connect from the local machine and it is only intended for testing.
  • A test database only intended for testing.

Check our recommendations for a production server.

MariaDB version

In order to see which MariaDB version are your machine running you can execute the following command:

$ mysqld --version

MariaDB configuration file

The MariaDB configuration file is located at installdir/mariadb/my.cnf.

The MariaDB official documentation has more details about how to configure the MariaDB database.

MariaDB socket

On Unix, MariaDB clients can connect to the server in the local machine using an Unix socket file at installdir/mariadb/tmp/mysql.sock.

MariaDB port

The default port for MariaDB is 3306.

MariaDB Process Identification Number

The MariaDB .pid file allows other programs to find out the PID (Process Identification Number) of a running script. Find it at installdir/mariadb/data/mysqld.pid.

MariaDB log file

The log-error file contains information indicating when MariaDB was started and stopped and also any critical errors that occur while the server is running. If MariaDB notices a table that needs to be automatically checked or repaired, it writes a message to the error log. Find it at installdir/mariadb/data/mysqld.log.

How to find the database credentials?

  • Database username: root.
  • Database password: The password entered during the installation process.

How to connect to the MariaDB database?

You can connect to the MariaDB database from the same computer where it is installed with the mysql client tool.

$ mysql -u root -p

You will be prompted to enter the root user password. This is the same as the application password.

How to connect to MariaDB from a different machine?

IMPORTANT: Bitnami Native Installers do not modify the firewall configuration of your computer, therefore the MariaDB ports could be open which is a significant security risk. You are strongly advised to close the MariaDB ports (refer to the FAQ for more information on this).

Once you have an active SSH tunnel or if you did not close the port for remote access, you can then connect to MariaDB using a command like the one below.

Remember to replace SOURCE-PORT with the source port number specified in the SSH tunnel configuration or 3306 if you did not close the port for remote access.

$ mysql -h 127.0.0.1 -P SOURCE-PORT -u root -p

You will be prompted to enter the root user password. This is the same as the application password.

How to create a database for a custom application?

These are the basic steps to create a new database and user for your applications:

  • Create a new database:

     MariaDB> create database DATABASE_NAME;
     Query OK, 1 row affected (0.00 sec)
    
  • Create a new user (only with local access) and grant privileges to this user on the new database:

     MariaDB> grant all privileges on DATABASE_NAME.* TO 'USER_NAME'@'localhost' identified by 'PASSWORD';
     Query OK, 1 row affected (0.00 sec)
    
  • Create a new user (with remote access) and grant privileges to this user on the new database:

     MariaDB> grant all privileges on DATABASE_NAME.* TO 'USER_NAME'@'%' identified by 'PASSWORD';
     Query OK, 1 row affected (0.00 sec)
    
  • After modifying the MariaDB grant tables, execute the following command in order to apply the changes:

     MariaDB> flush privileges;
     Query OK, 1 row affected (0.00 sec)
    

Some applications require specific privileges in the database. Check the MariaDB official documentation for getting, installing, and upgrading MariaDB.

How to reset the MariaDB root password?

Please note that depending on the version you have installed, you may find the MariaDB files at installdir/mysql

If you don't remember your MariaDB root password, you can follow the steps below to reset it to a new value:

  • Create a file in /home/bitnami/mysql-init with the content shown below (replace NEW_PASSWORD with the password you wish to use):

     UPDATE mysql.user SET Password=PASSWORD('NEW_PASSWORD') WHERE User='root';
     FLUSH PRIVILEGES;
    
  • Stop the MariaDB server:

     $ sudo installdir/ctlscript.sh stop mariadb
    
  • Start MariaDB with the following command:

     $ sudo installdir/mariadb/bin/mysqld_safe --defaults-file=installdir/mariadb/my.cnf --pid-file=installdir/mariadb/data/mysqld.pid --init-file=/home/bitnami/mysql-init 2> /dev/null &
    
  • Restart the MariaDB server:

     $ sudo installdir/ctlscript.sh restart mariadb
    
  • Remove the init script

     $ rm /home/bitnami/mysql-init
    

How to change the MariaDB root password?

You can modify the MariaDB password using the following command at the shell prompt:

$ installdir/mariadb/bin/mysqladmin -p -u root password NEW_PASSWORD

How to create a database backup?

To back up all the databases, create a dump file using the mysqldump tool.

$ mysqldump -A -u root -p > backup.sql

This operation could take some time depending on the database sizes.

NOTE: The steps previously described will only back up the data contained inside your databases. There may be other files that you should take into account when performing a full backup, such as files that may have been uploaded to your application. Refer to your application's documentation for more details.

How to restore a database backup?

Once you have the backup file, you can restore it with a command like the one below:

$ mysql -u root -p < backup.sql

How to secure your server?

Once you have created a new database and user for your application, connect to your MariaDB server and follow these recommendations:

  • Remove anonymous users:

     MariaDB> DELETE FROM mysql.user WHERE User='';
    
  • Remove the test database and access to it:

     MariaDB> DROP DATABASE test;
     MariaDB> DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%';
    
  • Disallow root login remotely:

     MariaDB> DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
    

    Don't forget to reload the privileges tables to apply the changes:

     MariaDB> FLUSH PRIVILEGES;
    
  • Change your root user password.

  • It is strongly recommended that you do not have empty passwords for any user accounts when using the server for any production work.

  • If you don't need remote access, uncomment the line

     #bind-address=127.0.0.1
    

    in the MariaDB configuration file to only listen for connections on the local machine. Restart the server once done.

How to debug errors in your database?

Please note that depending on the version you have installed, you may find the MariaDB files at installdir/mysql

The main log file is created at installdir/mariadb/data/mysqld.log on the MySQL database server host.

How to recover a MariaDB database with errors?

Before trying to recover a MariaDB database, you should check the exact error in the MariaDB log file at installdir/mariadb/data/mysqld.log. Check the latest entries in the MariaDB log file with the following command:

$ sudo tail -n 100 installdir/mariadb/data/mysqld.log

In this case, assume the following error in the log file:

110108 10:37:45 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'user' is marked as crashed

Here are some steps to resolve this error:

  • The MariaDB database is configured to use InnoDB engine by default. You can add the innodb_force_recovery=1 option in the main MariaDB configuration file at installdir/mariadb/my.cnf to try and fix the database:

     [mysqld]
     innodb_force_recovery = 1
    
  • Start the MariaDB database with the following command:

     $ mysqld --skip-grant-tables --user=mysql --pid-file=installdir/mariadb/data/mysqld.pid
     --skip-external-locking --port=3306 --sock=installdir/mariadb/tmp/mysql.sock
    
  • Open a new console and try to log in the database:

     $ mysql -u root -p
    
  • In this case, the error was related to the mysql.user table. Run these commands:

     MariaDB> use mysql;
     MariaDB> repair table user;
     MariaDB> check table user;
     MariaDB> exit;
    

If the table is recovered, you should see "OK" in the mysql.user status table. Do not forget to remove the innodb_force_recovery option from the my.cnf file and restart the MariaDB server again.

$ sudo installdir/ctlscript.sh restart mariadb

If you find a different error or cannot fix an issue, we can try to help at http://community.bitnami.com.

How to change the data directory?

The data directory for MariaDB is set to installdir/mariadb/data by default. You can modify the location of this folder modifying the installdir/mariadb/my.cnf file, as shown below:

...
datadir=installdir/mariadb/data
...

Also modify the installdir/mariadb/scripts/ctl.sh file to reflect the new directory location:

--datadir=installdir/mariadb/data

Finally, move the data/ directory to the new location and restart the database.

nativeInstaller