源码安装 MariaDB

官方文档

一、安装依赖组件

[root@localhost ~]# yum -y install gcc gcc-c++ make cmake ncurses ncurses libxml2 libxml2-devel openssl-devel bison bison-devel

二、安装第三方扩展库

[root@localhost src]# tar zxf libevent-2.0.21-stable
[root@localhost src]# cd libevent-2.0.21-stable
[root@localhost libevent-2.0.21-stable]# ./configure ; make ; make install

三、安装 MariaDB

[root@localhost src]# groupadd mariadb
[root@localhost src]# useradd -r -s /sbin/nologin -g mariadb mariadb

[root@localhost src]# tar zxf mariadb-10.0.10.tar.gz
[root@localhost src]# cd mariadb-10.0.10
[root@localhost mariadb-10.0.10]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb
[root@localhost mariadb-10.0.10]# make ; make install

[root@localhost local]# chown -R root.mariadb mariadb
[root@localhost local]# chown -R mariadb mariadb/data

[root@localhost local]# cp mariadb/support-files/mysql.server /etc/init.d/mariadbd
[root@localhost local]# cp mariadb/support-files/my-medium.cnf /etc/my.cnf

[root@localhost local]# ./mariadb/scripts/mysql_install_db --user=mariadb --basedir=/usr/local/mariadb/ --datadir=/usr/local/mariadb/data/

[root@localhost ~]# vim /etc/my.cnf
 28 [mysqld]
 29 user = mariadb  
      ##  指定运行用户身份,不然会无法启动出现无限..... 可以查看 --datadir= 目录下的 .err 文件了解情况

四、启动 MariaDB

[root@localhost ~]# service mariadbd start
Starting MySQL.. SUCCESS!
[root@localhost ~]# cp /etc/profile /etc/profile.bak
[root@localhost ~]# echo "PATH=$PATH:/usr/local/mariadb/bin/" >> /etc/profile
[root@localhost ~]# source /etc/profile
[root@localhost ~]# mysqladmin -u root -p password 123456
Enter password:  ## 默认空密码,直接按 Enter 键

[root@localhost ~]# mysql -u root -p123456
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 10.0.10-MariaDB-log Source distribution
Copyright (c) 2000, 2014, Oracle, SkySQL Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> quit
Bye

五、MariaDB 加入开机启动

[root@localhost ~]# chkconfig --add mariadbd
[root@localhost ~]# chkconfig --level 35 mariadbd on

##  收工  如果想外连数据库的话,iptables 需要开放 tcp 3306 端口


你可能感兴趣的:(mysql)