Installing MariaDB from Binary Tarballs
Download the binary tarball from the official MariaDB website. Ensure you select a version that aligns with your requirements; for instance, MariaDB 10.2 is functionally equivalent to MySQL 5.7.
Consult the official installation guide for binary tarballs to understand the process. Before proceeding, prepare the main configuration file /etc/my.cnf. A typical minimal configuration includes:
[client-server]
!includedir /etc/my.cnf.d
This directive includes all configuraton files within the /etc/my.cnf.d directory. Create separate files in this directory for specific purposes. For client utilities, create mysql-clients.cnf:
[mysql]
[mysql_upgrade]
[mysqladmin]
[mysqlbinlog]
[mysqlcheck]
[mysqldump]
[mysqlimport]
[mysqlshow]
[mysqlslap]
For server-specific settings, create server.cnf. Below is an example configuration:
[server]
[mysqld]
innodb_file_per_table = ON
skip_name_resolve = ON
character_set_server = utf8
basedir = /usr/local/mysql
datadir = /Data/mysqlData
default_storage_engine = innodb
[galera]
#wsrep_on=ON
#wsrep_provider=
#wsrep_cluster_address=
#binlog_format=row
#default_storage_engine=InnoDB
#innodb_autoinc_lock_mode=2
#bind-address=0.0.0.0
#wsrep_slave_threads=1
#innodb_flush_log_at_trx_commit=0
[embedded]
[mariadb]
[mariadb-10.2]
Initialize the data directory using the installation script. Navigate to the extracted tarball directory and execute:
./scripts/mysql_install_db --ldata=/Data/mysql --skip-name-resolve --user=mysql
Set up a systemd service file to manage the MariaDB daemon, then start and enable the service.
Run the security enhancement script to harden the installation:
mysql_secure_installation
After installation, you might encounter a situation where the local root login does not require a password, even after settting one via the security script. To enforce password authentication, connect to the MariaDB server and execute the following SQL commands. First, generate a password hash for your desired password:
SELECT PASSWORD('your_new_password');
Use the resulting hash in the following statement, replacing the example hash with your own:
ALTER USER root@localhost IDENTIFIED VIA mysql_native_password USING '*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B';
FLUSH PRIVILEGES;
For comprehensive details on MariaDB configuration files and options, refer to the official documentation.