标签:mariadb 编译安装
环境:
CentOS6.9
软件版本
编译安装 mariadb-10.2.12.tar.gz
1查询本地是否已经安装mysql(卸载之否则会报错);
rpm -qa | grep mysql
[root@user ~ 13]#rpm -qa | grep mysql
2.安装相关开发包组:
yum -y groupinstall development tools
yum cmake ncurses-devel gnutls-devel libaio-devel
3.查询用户:(若用户已经存在不用常见)
getent passwd mysql
[root@user ~ 16]#getent passwd mysql
4..创建mysql系统用户:
useradd -r mysql -s /sbin/nologin
[root@user ~ 17]#useradd -r mysql -s /sbin/nologin
mysql:x:990:305::/home/mysql:/sbin/nologin
5.解压源码包 mariadb-10.2.12.tar.gz
tar xvf mariadb-10.2.12.tar.gz -C /usr/local/
[root@user ~ 25]#tar xvf mariadb-10.2.12.tar.gz -C /usr/local/
6.cd进解压目录
[root@user ~ 25]#cd /usr/local/
[root@user /usr/local 26]#ls
bin etc games include lib lib64 libexec mariadb-10.2.12 mysql sbin share src
7..执行cmake make && make install (预计时间30分钟)
cmake .
-DCMAKE_INSTALL_PREFIX=/app/mysql
-DMYSQL_DATADIR=/mysqldb/
-DSYSCONFDIR=/etc
-DMYSQL_USER=mysql
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_READLINE=1
-DWITH_SSL=system
-DWITH_ZLIB=system
-DWITH_LIBWRAP=0
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock
-DENABLED_LOCAL_INFILE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
-DWITH_DEBUG=0
-DWITHOUT_MROONGA_STORAGE_ENGINE=1
make && make install
8.把/app目录下的mysql目录 属主mysql 属组mysql
chown -R mysql.mysql mysql/ (危险操作)
9.准备mysql的配置文件;support-file目录里所有以.cnf结尾的配置模版文件拷贝到etc下加以修改即可:
cp -a myhuge.cnf /etc/my.cnf (-a 保留权限)
10.拷贝mysql.server 文件到 /etc/init.d/mysqld.sh(启动fw)
cp -a mysql.server /etc/init.d/mysqld.sh
11.初始化数据库:
cd /app/mysql/
scripts/mysql_installl_db --user=mysql --datadir=/data/mtsqldb
指定以mysql用户的身份 路径在配置文件指定(数据存放位置) 也可以写在这里
=看到OK 没有报错表示初始化成功;
=
=12.添加开机启动
#chkconfig --add mysqld
#chkconfig mysqld on
[root@centos7 /app/mysql 106]#chkconfig --list mysqld
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use ‘systemctl list-unit-files‘.
To see services enabled on particular target use
‘systemctl list-dependencies [target]‘.
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
13.启动服务:
#systemctl start mysqld
ss -tnl 查看3306是否处于监听状态
14.编译安装完成
mysql默认没有密码 记得设置mysql root用户的密码 运行安全脚本
标签:mariadb 编译安装
原文地址:http://blog.51cto.com/37003839/2088124