标签:安装mysql
一、实验环境二、操作脚本
1.光盘挂载
cd /mnt
ls
mount /dev/cdrom /mnt
2.建立yum仓库
cd /etc/yum.repos.d/
vim aaa.repo
> [aaa]
> name=test
> baseurl=file:///mnt
> enabled=1
> gpgcheck=0
ls
rm -rf rhel-source.repo
yum list
3.共享挂载
mkdir /opt/lamp
smbclient -L //192.168.119.2/
mount.cifs //192.168.119.2/john /opt/lamp
4.文件的解压缩
cd /opt/lamp
tar zxvf mysql-5.5.24.tar.gz -C /opt
5.安装环境包
yum install gcc gcc-c++ make cmake -y
rpm -ivh /mnt/Packages/ncurses-devel-5.7-3.20090208.el6.x86_64.rpm
rpm -ivh /mnt/Packages/bison-2.4.1-5.el6.x86_64.rpm
rpm -ivh /mnt/Packages/libaio-devel-0.3.107-10.el6.x86_64.rpm
6.添加mysql用户并加入到mysql组
useradd -s /sbin/nologin mysql
mkdir -p /usr/local/mysql
7.编译安装
cd /opt/mysql-5.5.24
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_UNIX_ADDR=/home/mysql/mysql.sock
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DWITH_EXTRA_CHARSETS=all
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_MEMORY_STORAGE_ENGINE=1
-DWITH_READLINE=1
-DENABLED_LOCAL_INFILE=1
-DMYSQL_DATADIR=/home/mysql
-DMYSQL_USER=mysql
-DMYSQL_TCP_PORT=3306make && make install
8.递归复制
chown -R mysql.mysql /usr/local/mysql
9.开机时刷新
export PATH=$PATH:/usr/local/mysql/bin/
10.复制配置文件
cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
11.增加文件执行权限
chmod 755 /etc/init.d/mysqld
12.添加并启动mysqld服务
chkconfig --add /etc/init.d/mysqld
chkconfig mysqld --level 35 on
13.初始化数据库
/usr/local/mysql/scripts/mysql_install_db \
--user=mysql \
--ldata=/var/lib/mysql \
--basedir=/usr/local/mysql \
--datadir=/home/mysql
14.建立软链接
ln -s /var/lib/mysql/mysql.sock /home/mysql/mysql.sock
15.修改配置文件
vim /etc/init.d/mysqld
> basedir=/usr/local/mysql
> datadir=/home/mysql
16.开启mysqld服务并验证
service mysqld start
netstat -tnl 3306
cd /opt/mysql-5.5.24
mysql
show databases;
三、实验步骤示图
四、实验结果
结果表明:mysql安装成功,如下图
标签:安装mysql
原文地址:http://blog.51cto.com/13643697/2122921