Mariadb Installation Example

1. Check package
# rpm -qa | grep -i mariadb
mariadb-libs-5.5.56-2.el7.x86_64
mariadb-5.5.56-2.el7.x86_64
mariadb-server-5.5.56-2.el7.x86_64
2. Identify my.cnf
# cat  /etc/my.cnf

        [mysqld]
        datadir=/var/lib/mysql
        socket=/var/lib/mysql/mysql.sock
        # Disabling symbolic-links is recommended to prevent assorted security risks
        symbolic-links=0
        # Settings user and group are ignored when systemd is used.
        # If you need to run mysqld under a different user or group,
        # customize your systemd unit file for mariadb according to the
        # instructions in http://fedoraproject.org/wiki/Systemd
        [mysqld_safe]
        log-error=/var/log/mariadb/mariadb.log
        pid-file=/var/run/mariadb/mariadb.pid
        #
        # include all files from the config directory
        #
        !includedir /etc/my.cnf.d

3. Identify other files
# ls  -al /usr/bin/my*
-rwxr-xr-x. 1 root root 3417896 Jun  8 23:34 /usr/bin/myisamchk
-rwxr-xr-x. 1 root root 3293832 Jun  8 23:34 /usr/bin/myisam_ftdump
-rwxr-xr-x. 1 root root 3279992 Jun  8 23:34 /usr/bin/myisamlog
-rwxr-xr-x. 1 root root 3319056 Jun  8 23:34 /usr/bin/myisampack
-rwxr-xr-x. 1 root root 2917944 Jun  8 23:34 /usr/bin/my_print_defaults
-rwxr-xr-x. 1 root root 3539400 Jun  8 23:34 /usr/bin/mysql
-rwxr-xr-x. 1 root root  111587 Jun  8 23:30 /usr/bin/mysqlaccess
-rwxr-xr-x. 1 root root 3092608 Jun  8 23:34 /usr/bin/mysqladmin
-rwxr-xr-x. 1 root root 3255968 Jun  8 23:34 /usr/bin/mysqlbinlog
lrwxrwxrwx. 1 root root      26 Aug  3 19:39 /usr/bin/mysqlbug -> /etc/alternatives/mysqlbug
-rwxr-xr-x. 1 root root 3094128 Jun  8 23:34 /usr/bin/mysqlcheck
-rwxr-xr-x. 1 root root    4247 Jun  8 23:30 /usr/bin/mysql_convert_table_format
-rwxr-xr-x. 1 root root   24886 Jun  8 23:30 /usr/bin/mysqld_multi
-rwxr-xr-x. 1 root root   26977 Jun  8 23:30 /usr/bin/mysqld_safe
-rwxr-xr-x. 1 root root 2887136 Jun  8 23:34 /usr/bin/mysqld_safe_helper
-rwxr-xr-x. 1 root root 3176744 Jun  8 23:34 /usr/bin/mysqldump
-rwxr-xr-x. 1 root root    7913 Jun  8 23:30 /usr/bin/mysqldumpslow
-rwxr-xr-x. 1 root root    3315 Jun  8 23:30 /usr/bin/mysql_find_rows
-rwxr-xr-x. 1 root root    1261 Jun  8 23:30 /usr/bin/mysql_fix_extensions
-rwxr-xr-x. 1 root root   34941 Jun  8 23:30 /usr/bin/mysqlhotcopy
-rwxr-xr-x. 1 root root 3089024 Jun  8 23:34 /usr/bin/mysqlimport
-rwxr-xr-x. 1 root root   16019 Jun  8 23:30 /usr/bin/mysql_install_db
-rwxr-xr-x. 1 root root 2926216 Jun  8 23:34 /usr/bin/mysql_plugin
-rwxr-xr-x. 1 root root   12126 Jun  8 23:30 /usr/bin/mysql_secure_installation
-rwxr-xr-x. 1 root root   17485 Jun  8 23:30 /usr/bin/mysql_setpermission
-rwxr-xr-x. 1 root root 3087744 Jun  8 23:34 /usr/bin/mysqlshow
-rwxr-xr-x. 1 root root 3106928 Jun  8 23:34 /usr/bin/mysqlslap
-rwxr-xr-x. 1 root root 3449088 Jun  8 23:34 /usr/bin/mysqltest
-rwxr-xr-x. 1 root root 2921424 Jun  8 23:34 /usr/bin/mysql_tzinfo_to_sql
-rwxr-xr-x. 1 root root 2998504 Jun  8 23:34 /usr/bin/mysql_upgrade
-rwxr-xr-x. 1 root root 2912992 Jun  8 23:34 /usr/bin/mysql_waitpid
-rwxr-xr-x. 1 root root    3888 Jun  8 23:30 /usr/bin/mysql_zap
4. Identify user
# cat /etc/passwd | grep mysql
mysql:x:27:27:MariaDB Server:/var/lib/mysql:/sbin/nologin
5. Install
[root@localhost bin]# ./mysql_install_db  --user=mysql

  Installing MariaDB/MySQL system tables in '/var/lib/mysql' ...
  170107 13:40:55 [Note] /usr/libexec/mysqld (mysqld 5.5.56-MariaDB) starting as process 32766 ...
  OK
  Filling help tables...
  170107 13:40:55 [Note] /usr/libexec/mysqld (mysqld 5.5.56-MariaDB) starting as process 306 ...
  OK
  To start mysqld at boot time you have to copy
  support-files/mysql.server to the right place for your system
  PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
  To do so, start the server, then issue the following commands:
  '/usr/bin/mysqladmin' -u root password 'new-password'
  '/usr/bin/mysqladmin' -u root -h localhost.localdomain password 'new-password'
  Alternatively you can run:
  '/usr/bin/mysql_secure_installation'
  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 http://mariadb.com/kb or the
  MySQL manual for more instructions.
  You can start the MariaDB daemon with:
  cd '/usr' ; /usr/bin/mysqld_safe --datadir='/var/lib/mysql'
  You can test the MariaDB daemon with mysql-test-run.pl
  cd '/usr/mysql-test' ; perl mysql-test-run.pl
  Please report any problems at http://mariadb.org/jira
  The latest information about MariaDB is available at http://mariadb.org/.
  You can find additional information about the MySQL part at:
  http://dev.mysql.com
  Consider joining MariaDB's strong and vibrant community:
  https://mariadb.org/get-involved/

[root@localhost bin]#
6. Start db
# /usr/bin/mysqld_safe --datadir='/var/lib/mysql' &  
#
#
#  ps -ef | grep mysql
mysql      768     1  0 13:43 pts/0    00:00:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql 
                                                --plugin-dir=/usr/lib64/mysql/plugin --user=mysql 
                                                --log-error=/var/log/mariadb/mariadb.log 
                                                --pid-file=/var/run/mariadb/mariadb.pid 
                                                --socket=/var/lib/mysql/mysql.sock
#
7. Identify listen port
# netstat -an | grep 3306
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN     
8. Connect as root user
# mysql -uroot
Welcome to the MariaDB.  Commands end with ; or \g.
Your MariaDB connection id is 1
Server version: 5.5.56-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> 
9. Create Database and User
# cat /etc/hosts

192.168.25.50   monitor
127.0.0.1       localhost localhost.localdomain localhost4 localhost4.localdomain4
::1             localhost localhost.localdomain localhost6 localhost6.localdomain6



# mysql -uroot
Welcome to the MariaDB.  Commands end with ; or \g.
Your MariaDB connection id is 1
Server version: 5.5.56-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> 
MariaDB [(none)]>
MariaDB [(none)]>
MariaDB [(none)]> create database zamong default character set ascii ;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zamong.* to 'mong'@'%'  identified by 'aaaaa' ;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zamong.* to 'mong'@'localhost' identified by 'aaaaa' ;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zamong.* to 'mong'@'monitor' identified by 'aaaaa' ;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges ;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit
Bye
#
9. Check Firewall (cenos 6.x )
# iptables -A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT
#
#
# iptables -L
Chain INPUT (policy DROP)
target     prot opt source               destination                   
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 
ACCEPT     icmp --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ncube-lm 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:mysql 
         
Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
10. Check Firewall (cenos 7.x )
# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
#
#
#systemctl list-unit-files --type=service | grep firewall
firewalld.service                           enabled
#
#firewall-cmd --permanent --zone=public --add-port=3306/tcp
#firewall-cmd --reload         
11. Connect as zamong user
# mysql -u mong -paaaaa -D zamong -h 192.168.25.50
Welcome to the MariaDB .  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.56-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [zamong]>        
12. Run zamong server
zamong@monitor:/home/zamong/zsvr> ./zamongsvrctl start
Starting zamong_svr process. Please refer to the zamong_server.log file for detail
Wait for checking
....
USER   PID     PROCESS
zamong      2420 zamong_svr





[ Note: If error is as follows, please check LD_LIBRARY_PATH.
     ./zamong_svr: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory

    you have to check the path of libmysqlclient.so.18 file.
    find / -name libmysqlclient.so.18     or 
    find / -name "libmysqlclient*"
    and set LD_LIBRARY_PATH  environment variable.

    export LD_LIBRARY_PATH=/data/mysql/lib 
    echo   $LD_LIBRARY_PATH    


zamong@monitor /data/mysql/lib> ls -al
drwxr-xr-x.  3 mysql mysql      4096 2017-06-01 18:20 .
drwxr-xr-x. 13 mysql mysql      4096 2017-09-12 15:52 ..
-rw-r--r--.  1 mysql mysql  17473438 2015-08-06 04:13 libmysqlclient.a
lrwxrwxrwx.  1 mysql mysql        20 2016-08-30 22:36 libmysqlclient.so -> libmysqlclient.so.18
lrwxrwxrwx.  1 mysql mysql        24 2016-08-30 22:36 libmysqlclient.so.18 -> libmysqlclient.so.18.0.0
-rwxr-xr-x.  1 mysql mysql   8288200 2015-08-06 04:13 libmysqlclient.so.18.0.0

root@monitor /data/mysql/lib> cp libmysqlclient.so.18.0.0   /usr/lib64/mysql/libmysqlclient.so.18
root@monitor /data/mysql/lib> chmod 755   /usr/lib64/mysql/libmysqlclient.so.18
]
12. Identify zamong server log and table
# cat zamong_server.log 
20170207 14:05:23 server start
20170207 14:05:23 home_dir:
20170207 14:05:23 zamong_listen_port: 
20170207 14:05:23 db_server_ip: 
20170207 14:05:23 db_connection_port: 
20170207 14:05:23 db_connect_user:
20170207 14:05:23 first character of string_for_connection: 
20170207 14:05:23 database_name: 
20170207 14:05:23 table_check_interval: 

20170207 14:05:23 checking db connection....
20170207 14:05:27 complete checking

20170207 14:05:27 creating socket for listen...
20170207 14:05:27 server socket created
20170207 14:05:27 server socket bind complete
20170207 14:05:27 server listen

#
# mysql -u mong -paaaaa -D zamong -h 192.168.25.50
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 5.5.56-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [zamong]>
MariaDB [zamong]>
MariaDB [zamong]> show tables ;
+------------------+
| Tables_in_zamong |
+------------------+
| time_dt          |
+------------------+
1 row in set (0.00 sec)
MariaDB [zamong]>
MariaDB [zamong]>
Command to start and stop Mariadb or Mysql
# pwd
/data/mysql


# ls -al
-rw-r--r--.  1 mysql mysql   17987 2015-08-06 03:11 COPYING
-rw-r--r--.  1 mysql mysql   26545 2015-08-06 03:11 COPYING.LESSER
-rw-r--r--.  1 mysql mysql    1553 2015-08-06 03:11 CREDITS
-rw-r--r--.  1 mysql mysql    8245 2015-08-06 03:11 EXCEPTIONS-CLIENT
-rw-r--r--.  1 mysql mysql    8694 2015-08-06 03:11 INSTALL-BINARY
-rw-r--r--.  1 mysql mysql   90897 2015-08-06 03:11 README
drwxr-xr-x.  2 mysql mysql    4096 2015-10-23 14:01 bin
drwxr-xr-x.  8 mysql mysql    4096 2017-09-24 21:11 data
drwxr-xr-x.  3 mysql mysql    4096 2017-06-01 16:35 include
drwxr-xr-x.  3 mysql mysql    4096 2017-06-01 18:20 lib
drwxr-xr-x.  4 mysql mysql    4096 2015-10-23 09:56 man
-rw-r--r--   1 mysql mysql    2827 2017-09-12 15:52 my.cnf
drwxr-xr-x. 11 mysql mysql    4096 2015-10-23 09:56 mysql-test
-rwxr-xr-x.  1 mysql mysql   12231 2015-10-23 14:03 mysql.server
drwxr-xr-x.  2 mysql mysql    4096 2015-10-23 09:56 scripts
drwxr-xr-x. 28 mysql mysql    4096 2015-10-23 09:56 share
drwxr-xr-x.  4 mysql mysql    4096 2015-10-23 09:56 sql-bench
-rwx------.  1 mysql mysql      47 2015-11-01 20:48 start.sh
-rwx------.  1 mysql mysql      28 2015-11-01 20:48 stop.sh 
drwxr-xr-x.  3 mysql mysql    4096 2015-10-23 09:56 support-files
drwxr-xr-x.  2 mysql mysql    4096 2015-10-23 14:02 tmp

# cat start.sh
 ./bin/mysqld_safe --defaults-file=./my.cnf & 



# cat stop.sh
 mysqladmin -uroot shutdown 
 #  ( use -p option, if password is need )  


Other Tutorials

Zamong Setup
Installation and Configuration of Apache Http Server (RPM) on Centos
Installation and Configuration of PHP