安装步骤:
1.准备
1.1 显示系统版本
[root@centos ~]# cat /etc/redhat-releaseCentOS Linux release 7.0.1406 (Core) [root@centos ~]# uname -aLinux tCentos7 3.10.0-123.9.3.el7.x86_64 #1 SMP Thu Nov 6 15:06:03 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
1.2 安装基本软件包
[root@centos ~]# yum install vim wget lsof gcc gcc-c++ -y
[root@centos ~]# yum install net-tools bind-utils -y
1.3 显示IP地址 (centos7需要先安装 net-tools bind-utils包)
[root@centos ~]# ifconfig|grep inet
inet 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.255
2.安装mariadb 2.1 安装依赖[root@centos ~]# yum install ncurses-devel openssl* bzip2 m4 -y 2.2 安装cmake[root@centos ~]# cd /usr/local/src/
[root@centos ~]# tar zvxf cmake-3.0.0.tar.gz
[root@centos ~]# cd cmake-3.0.0
[root@centos ~]# ./bootstrap
[root@centos ~]# make && make install
2.3 安装bison(需要 m4 库)[root@centos ~]# cd /usr/local/src/
[root@centos ~]# tar zvxf bison-3.0.tar.gz
[root@centos ~]# cd bison-3.0
[root@centos ~]# ./configure
[root@centos ~]# make && make install
2.4 安装jemalloc(需要 bzip2 库解压)[root@centos ~]# cd /usr/local/src/
[root@centos ~]# tar xjf jemalloc-3.6.0.tar.bz2
[root@centos ~]# cd jemalloc-3.6.0
[root@centos ~]# ./configure
[root@centos ~]# make && make install
[root@centos ~]# echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
[root@centos ~]# ldconfig
2.5 创建mysql需要的目录、配置用户和用户组[root@centos ~]# groupadd mysql
[root@centos ~]# useradd -g mysql mysql -s /sbin/nologin
[root@centos ~]# mkdir -p /data/mysql
[root@centos ~]# chown -R mysql:mysql /data/mysql
2.6 编译mariadb(需要 cmake ncurses-devel bison 库)[root@centos ~]# cd /usr/local/src/
[root@centos ~]# tar zvxf mariadb-10.0.15.tar.gz
[root@centos ~]# cd mariadb-10.0.15
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_DATADIR=/data/mysql \ -DSYSCONFDIR=/etc \ -DWITHOUT_TOKUDB=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STPRAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWIYH_READLINE=1 \ -DWIYH_SSL=system \ -DVITH_ZLIB=system \ -DWITH_LOBWRAP=0 \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci
[root@centos ~]# make
[root@centos ~]# make install
2.8 修改配置文件
[root@centos ~]# cd /opt/mysql
[root@centos ~]# cp ./support-files/my-large.cnf /etc/my.cnf
[root@centos ~]# vim /etc/my.cnf
在[client]下添加一行
default-character-set = utf8在[mysqld]下添加一行
datadir = /data/mysqlcharacter-set-server = utf8保存退出
> 进入到 MariaDB 安装目录[root@localhost ~]# cd /usr/local/mysql/> 使用 `mysql` 用户执行脚本, 安装数据库到数据库存放目录[root@localhost mysql]# scripts/mysql_install_db --user=mysql --datadir=/data/mysql> 输出以下信息:Installing MariaDB/MySQL system tables in '/data/mysql' ...OKTo start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your systemPLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !To do so, start the server, then issue the following commands:'./bin/mysqladmin' -u root password 'new-password''./bin/mysqladmin' -u root -h localhost.localdomain password 'new-password'Alternatively you can run:'./bin/mysql_secure_installation'which will also give you the option of removing the testdatabases and anonymous user created by default. This isstrongly recommended for production servers.See the MariaDB Knowledgebase at http://mariadb.com/kb or theMySQL manual for more instructions.You can start the MariaDB daemon with:cd '.' ; ./bin/mysqld_safe --datadir='/data/maria'You can test the MariaDB daemon with mysql-test-run.plcd './mysql-test' ; perl mysql-test-run.plPlease report any problems at http://mariadb.org/jiraThe latest information about MariaDB is available at http://mariadb.org/.You can find additional information about the MySQL part at:http://dev.mysql.comConsider joining MariaDB's strong and vibrant community:https://mariadb.org/get-involved/
创建启动脚本
[root@localhost mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
启动mysqld服务
[root@localhost mysql]# /etc/rc.d/init.d/mysqld start