标签:linux
安装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 %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 mysqd /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 & 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%] 在 mysqd 服务中读取信息时出错:没有那个文件或目录 [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包安装的时候会显示这些信息,但是不影响,不知道怎么屏蔽这些信息,求指教
标签:linux
原文地址:http://kingtigerhu.blog.51cto.com/2936525/1772979