rpm打包mysql_rpm打包mysql5.5

安装rpm-build

[root@master ~]# yum install rpm-build

创建工作目录

[root@master ~]# mkdir -p /root/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}

[root@master ~]# cp mysql-5.5.27.tar.gz /root/rpmbuild/SOURCES/

[root@master ~]# cp my.cnf /root/rpmbuild/SOURCES/

[root@master ~]# cp mysqld /root/rpmbuild/SOURCES/

[root@master ~]# cd /root/rpmbuild/SPECS/

[root@master SPECS]# vim mysql.spec

Name: mysql

Version: 5.5.27

Release:        1%{?dist}

Summary: mysql-5.5.27.tar.gz to mysql-5.5.27.rpm

Group: Applications/Archiving

License:GPL

URL: http://www.cnblogs.com/kingtigerhu

Vendor: knight

Source0: %{name}-%{version}.tar.gz

Source1: mysqld

Source2: my.cnf

BuildRequires: cmake

Requires: ncurses-devel

Autoreq: no

Autoprov : no

%description

Build mysql-5.5.27.tar.gz to mysql-5.5.27.rpm

%prep

%setup -q

%build

//编译的时候会报错,所以把%configure删除了

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DMYSQL_DATADIR=/usr/local/mysql/data \

-DSYSCONFDIR=/etc \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_MEMORY_STORAGE_ENGINE=1 \

-DWITH_READLINE=1 \

-DMYSQL_TCP_PORT=3306 \

-DENABLED_LOCAL_INFILE=1 \

-DWITH_PARTITION_STORAGE_ENGINE=1 \

-DEXTRA_CHARSETS=all \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci

make %{?_smp_mflags}

%install

rm -rf %{buildroot}

make install DESTDIR=%{buildroot}

%{__install} -p -D -m 0755 %{SOURCE1} %{buildroot}/etc/rc.d/init.d/mysqld

%{__install} -p -D %{SOURCE2} %{buildroot}/etc/my.cnf

%pre

//$1有3个值,代表动作,安装类型,1表示安装,2表示升级,0表示卸载

if [ $1 == 1 ];then

/usr/sbin/useradd mysql 2> /dev/null

fi

%post

if [ $1 == 1 ];then

/sbin/chkconfig --add mysqld

/sbin/chkconfig mysqld on

echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile

source /etc/profile

chown -R mysql:mysql /usr/local/mysql

/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data > /dev/null 2>&1

fi

%preun

if [ $1 == 0 ];then

/usr/sbin/userdel mysql 2> /dev/null

/etc/init.d/mysqld stop > /dev/null 2>&1

fi

%postun

%clean

rm -rf %{buildroot}

%files

%defattr(-,root,root,0755)

/usr/local/mysql/

%attr(0755,root,root) /etc/rc.d/init.d/mysqld

%config(noreplace) /etc/my.cnf

%doc

%changelog

* Thu May 12 2016 knight <1908616619@qq.com> - 5.5.27-1

- Initial version

[root@master SPECS]# rpmbuild -bb mysql.spec

[root@master SPECS]# ll /root/rpmbuild/RPMS/x86_64/mysql-*

-rw-r--r-- 1 root root 28426984 5月  12 04:16 /root/rpmbuild/RPMS/x86_64/mysql-5.5.27-1.el6.x86_64.rpm

[root@slave2 ~]# rpm -ivh mysql-5.5.27-1.el6.x86_64.rpm --nodeps --force

Preparing...                ########################################### [100%]

1:mysql                  ########################################### [100%]

[root@slave2 ~]# Installing MySQL system tables...

OK

Filling help tables...

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 MySQL root USER !

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

/usr/local/mysql/bin/mysqladmin -u root password 'new-password'

/usr/local/mysql/bin/mysqladmin -u root -h slave2 password 'new-password'

Alternatively you can run:

/usr/local/mysql/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 manual for more instructions.

You can start the MySQL daemon with:

cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/local/mysql/scripts/mysqlbug script!

rpm包安装的时候会显示这些信息,但是不影响,不知道怎么屏蔽这些信息,求指教

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值