mariadb Source Installation

Keywords: MariaDB MySQL Linux mysqladmin

Dead work

Because MariaDB's binary package mirroring source is at a foreign address, the package is downloaded in advance to the local physical machine and uploaded to the virtual machine/usr/local/src directory for installation using the lrzsz tool.

The physical address is (click to download directly to the physical machine):

[root@adailinux src]# Yum install-y lrzsz //install lrzsz tool

[root@dl-001 ~]# Cd/usr/local/src //Upload local package to virtual terminal
[root@dl-001 src]# ls
[root@dl-001 src]# rz

[root@dl-001 src]# ls
mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz  mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz

1, Unzip Binary Compiled Package

[root@dl-001 src]# tar zxf mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz 

2, move to/usr/local/below

[root@dl-001 src]# mv mariadb-10.2.6-linux-glibc_214-x86_64 /usr/local/mariadb
[root@dl-001 local]# cd mariadb/

3, Initialization script, specify basedir and datadir

// Unlike mysql installation here, additional basedir needs to be specified

[root@dl-001 mariadb]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mariadb/ --datadir=/data/mariadb
Installing MariaDB/MySQL system tables in '/data/mariadb' ...

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

To do so, start the server, then issue the following commands:

'/usr/local/mariadb//bin/mysqladmin' -u root password 'new-password'
'/usr/local/mariadb//bin/mysqladmin' -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the MariaDB Knowledgebase at or the
MySQL manual for more instructions.

You can start the MariaDB daemon with:
cd '/usr/local/mariadb/' ; /usr/local/mariadb//bin/mysqld_safe --datadir='/data/mariadb'

You can test the MariaDB daemon with
cd '/usr/local/mariadb//mysql-test' ; perl

Please report any problems at

The latest information about MariaDB is available at
You can find additional information about the MySQL part at:
Consider joining MariaDB's strong and vibrant community:

4, copy the configuration file (select by server memory, here test select my-small.cnf)

# Here's how mysql and mariadb can coexist in one machine
# If you only have mariadb in your host machine, copy it directly to the / etc command and name it my.cnf; you can also modify the basedir
[root@dl-001 mariadb]# cp support-files/my-small.cnf /usr/local/mariadb/my.cnf
[root@dl-001 mariadb]# vi /usr/local/mariadb/my.cnf 
//Insert the following under [mysqld]

5, copy the startup script to / etc/init.d/directory and modify the contents

[root@dl-001 mariadb]# cp support-files/mysql.server /etc/init.d/mariadb
[root@dl-001 mariadb]# vi /etc/init.d/mariadb 
//Modify Content
confdir=$basedir/my.cnf    //Newly added

//Add the --defaults-file option to the boot entry below to load the specified configuration file
$bindir/mysqld_safe --defaults-file="$confdir" --datadir="$datadir" --pid-file="$mysqld_pid_file_path" "$@" &

6, Start the script and verify success

[root@dl-001 mariadb]# /etc/init.d/mariadb start
Reloading systemd:                                         [  Determine  ]
Starting mariadb (via systemctl):                          [  Determine  ]

[root@dl-001 mariadb]# ps aux | grep mysql
root       3466  0.5  0.1 115392  1736 ?        S    13:04   0:00 /bin/sh /usr/local/mariadb//bin/mysqld_safe --defaults-file=/usr/local/mariadb/my.cnf --datadir=/data/mariadb --pid-file=/data/mariadb/
mysql      3588 12.7  5.7 1125028 57864 ?       Sl   13:04   0:00 /usr/local/mariadb/bin/mysqld --defaults-file=/usr/local/mariadb/my.cnf --basedir=/usr/local/mariadb/ --datadir=/data/mariadb/ --plugin-dir=/usr/local/mariadb/lib/plugin --user=mysql --log-error=/data/mariadb/localhost.localdomain.err --pid-file=/data/mariadb// --socket=/tmp/mysql.sock --port=3306
root       3624  0.0  0.0 112676   972 pts/0    S+   13:04   0:00 grep --color=auto mysql

Posted by abo28 on Sun, 10 May 2020 09:09:17 -0700