首页 » 数据库 » Mysql » 正文

Linux下源码编译安装mysql-5.5.27.tar.gz

操作系统:Redhat Enterprise Linux 6.2

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

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

# groupadd mysql

# useradd -g mysql mysql

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

2. 安装所需相关库文件

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

3. 解压mysql-5.5.27.tar.gz

# cd /home/software/

# tar -zxvf mysql-5.5.27.tar.gz

4. 编译安装

# 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

5. 初始化数据库

# cd /usr/local/mysql/

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

6. 设置开机启动

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

# chkconfig mysqld on

7. 添加环境变量

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

# source /etc/profile

8. 启动mysql服务

# /etc/init.d/mysqld start

9. 装完后修改mysql密码和远程访问

# mysql -u root -p

Enter password:       默认无密码,直接回车

mysql>use mysql;

mysql> update user set password=password("123456");  //修改密码

mysql> update user set `host` = '%' where `user` = 'root' limit 1;   //修改可远程访问

mysql > exit  //退出

10. 重启mysql服务

# /etc/init.d/mysqld restart

发表评论

*