一、实验环境
在Linux系统中安装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安装成功,如下图
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。