首页 » 数据库 » Mysql » 正文

Linux下yum和源码安装Mysql

环境:CentOS 6.0_x64

开放端口:编辑/etc/sysconfig/iptables添加以下记录,保存后重启防火墙

-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT

一、方法一:yum安装

1. 安装 # yum -y install mysql-server mysql-devel mysql

2. 配置 见本博客Mysql分类  

二、方法二:源码编译安装

  1. 创建用户、目录和修改权限

# mkdir -p /usr/local/mysql/data

# groupadd mysql

# useradd -g mysql mysql

# chown -R mysql.mysql /usr/local/mysql/data/

  1. 安装所需相关库文件

# yum install -y gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* cmake

  1. 解压mysql-5.5.27.tar.gz

# cd /home/software/

# tar -zxv mysql-5.5.27.tar.gz

  1. 编译安装

# cd mysql-5.5.27

# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql

# make && make install

# cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf

  1. 初始化数据库

# cd /usr/local/mysql/

# scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql/ –datadir=/usr/local/mysql/data/

  1. 设置开机启动

# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

# chkconfig mysqld on

  1. 添加环境变量

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

# source /etc/profile

  1. 启动mysql服务

# /etc/init.d/mysqld start

  

发表评论

*