Centos-6.6源码安装MySQL-5.5
Posted it-art
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos-6.6源码安装MySQL-5.5相关的知识,希望对你有一定的参考价值。
1.安装环境
[root@linux-mysql-server ~]# cat /etc/redhat-release CentOS release 6.6 (Final) [root@linux-mysql-server ~]# uname -r 2.6.32-504.el6.x86_64
2.环境初始化
[root@linux-mysql-server ~]# /etc/init.d/iptables stop #关闭防火墙 [root@linux-mysql-server ~]# chkconfig iptables off #禁止开机自启动 [root@linux-mysql-server ~]# sed -ri ‘s#SELINUX=enforcing#SELINUX=disabled#g‘ /etc/selinux/config #关闭SElinux [root@linux-mysql-server ~]# setenforce 0 #临时关闭SElinux [root@linux-mysql-server ~]# ntpdate ntp.api.bz #时间同步 #添加定时任务 [root@linux-mysql-server ~]# echo "*/5 * * * * $(which ntpdate) ntp.api.bz &> /dev/null" >> /var/spool/cron/root
3.安装
[root@linux-mysql-server ~]# useradd -s /sbin/nologin -M mysql #解析主机名 [root@linux-mysql-server ~]# echo "$(ifconfig eth0|awk -F ‘[: ]+‘ ‘NR==2 print $4‘) $(hostname)" >> /etc/hosts #安装cmake编译工具和依赖库 [root@linux-mysql-server ~]# yum install cmake ncurses-devel –y [root@linux-mysql-server ~]# cd tools/ [root@linux-mysql-server tools]# tar -xf mysql-5.5.32.tar.gz [root@linux-mysql-server tools]# cd mysql-5.5.32 [root@linux-mysql-server mysql-5.5.32]# cmake -DCMAKE_INSTALL_PREFIX=/app/mysql-5.5.32 -DMYSQL_DATADIR=/app/mysql-5.5.32/data -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/app/mysql-5.5.32/data/mysqld.sock -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_READLINE=1 -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 [root@linux-mysql-server mysql-5.5.32]# make && make install [root@linux-mysql-server mysql-5.5.32]# ln -s /app/mysql-5.5.32 /app/mysql [root@linux-mysql-server mysql-5.5.32]# cd /app/mysql/scripts #初始化 [root@linux-mysql-server scripts ]# ./mysql_install_db --basedir=/app/mysql --datadir=/app/mysql/data/ --user=mysql 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: /app/mysql/bin/mysqladmin -u root password ‘new-password‘ /app/mysql/bin/mysqladmin -u root -h linux-mysql-server.com password ‘new-password‘ Alternatively you can run: /app/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 /app/mysql ; /application/mysql/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd /app/mysql/mysql-test ; perl mysql-test-run.pl Please report any problems with the /app/mysql/scripts/mysqlbug script! [root@linux-mysql-server scripts ]# /bin/cp /app/mysql/support-files/my-small.cnf /etc/my.cnf [root@linux-mysql-server scripts ]# /bin/cp /app/mysql/support-files/mysql.server /etc/init.d/mysqld #添加环境变量 [root@linux-mysql-server scripts ]# echo "export PATH=$PATH:/app/mysql/bin" >> /etc/profile [root@linux-mysql-server scripts ]# . /etc/profile [root@linux-mysql-server scripts ]# /etc/init.d/mysqld start #启动 [root@linux-mysql-server scripts ]# mysqladmin -uroot password #设置新密码
以上是关于Centos-6.6源码安装MySQL-5.5的主要内容,如果未能解决你的问题,请参考以下文章
高可用架构篇 MySQL源码编译安装(CentOS-6.6+MySQL-5.6)