111
先把自带的mysql移除
[root@localhost lib]# rpm -qa|grep mysql
mysql-devel-5.1.73-3.el6_5.x86_64
mysql-libs-5.1.73-3.el6_5.x86_64
mysql-5.1.73-3.el6_5.x86_64
[root@localhost ~]# yum remove mysql
由于源码编译时间太长,所以这里的是官网获得二进制安装包
[root@localhost ~]# wget http://dev.mysql.com/downloads/file.php?id=457697
[root@localhost ~]# tar xf mysql-5.6.25-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
[root@localhost ~]# cd /usr/local
[root@localhost local]# ln -sv mysql-5.6.25-linux-glibc2.5-x86_64 mysql
2 安装过程参照/解压目录/INSTALL_BINARY
[root@localhost local]# cd mysql
[root@localhost mysql]# more INSTALL-BINARY
总结如下:
shell> groupadd mysql
shell> useradd -r -g mysql mysql
所以
[root@localhost htdocs]# groupadd mysql
[root@localhost htdocs]# useradd -r -g mysql mysql
3 暂时修改安装目录下文件属主属组为mysql并执行安装脚本/安装目录/scripts/mysql_install_db
[root@localhost ~]# cd /usr/local/mysql
[root@localhost mysql]# chown -R mysql.mysql *
关于执行脚本注意加上选项,可以-h查看,--user=mysql --datadir=XX datadir建议使用一个独立的分区
下面添加一个LVM卷
由于我的centos没有空间了,所以在虚拟机中添加一个硬盘,具体是关机,然后设置,左边下面的添加,选择硬盘。
[root@localhost mysql]# fdisk /dev/sdb
Device Boot Start End Blocks Id System
/dev/sdb1 1 1306 10490413+ 8e Linux LVM
最后输入w,中间转换类型使用t
然后创建pv
[root@localhost ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
物理部分搞定,创建vg,记得指定名字
[root@localhost ~]# vgcreate vgdata /dev/sdb1
Volume group "vgdata" successfully created
创建lv
[root@localhost ~]# lvcreate -L +10G -n lvdata vgdata
Logical volume "lvdata" created
格式化lvdata
[root@localhost ~]# mke2fs -t ext4 /dev/vgdata/lvdata
[root@localhost ~]# mkdir /data/
[root@localhost ~]# mount /dev/vg
vga_arbiter vgdata/ vg_livecd/
[root@localhost ~]# mount /dev/vgdata/lvdata /data/
[root@localhost ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg_livecd-lv_root
ext4 19G 4.4G 14G 25% /
tmpfs tmpfs 238M 0 238M 0% /dev/shm
/dev/sda1 ext4 485M 34M 426M 8% /boot
/dev/mapper/vgdata-lvdata
ext4 9.9G 151M 9.2G 2% /data
开机挂载
[root@localhost ~]# echo "/dev/vgdata/lvdata /data ext4 defaults 0 0" >> /etc/fstab
b)执行安装脚本
[root@localhost mysql]# mkdir /data/mysql/
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
4安装完成把属主改为root,把data改为mysql用户,由于我们是放在新盘所以不用改咯
[root@localhost mysql]# chown -R root *
5 把support-files/mysql.server 可以复制到启动脚本里面
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld
修改文件
[root@localhost mysql]# vim /etc/init.d/mysql.server
basedir=/usr/local/mysql
datadir=/data/mysql
6 复制安装目录下的my.cnf 为/etc/my.cnf
主要修改mydatadir 、 user
[root@localhost ~]# cp /usr/local/mysql/my.cnf /etc/my.cnf
在主配置文件中发现sock等,其实还需要定义
7 额外的动作
[root@localhost mysql]# echo "/usr/local/mysql/lib" >> /etc/ld.so.conf.d/mysql.conf
[root@localhost mysql]# man mysql
No manual entry for mysql
所以需要加入man文档在/etc/man.config中加入一行MANPATH /usr/local/mysql/man
就可以使用man了
[root@localhost mysql]# mysql --help
-bash: mysql: command not found
[root@localhost mysql]# echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile.d/mysql.sh
[root@localhost mysql]# source /etc/profile.d/mysql.sh
mysql的相关命令就可以使用了
一般来说,为其在/usr/include创建相应的目录连接即可
[root@localhost ~]# ln -sv /usr/local/mysql/include /usr/include/mysql
`/usr/include/mysql‘ -> `/usr/local/mysql/include‘
3 启动我们的服务试试
[root@localhost ~]# netstat -tlnp|grep mysql
[root@localhost ~]#
[root@localhost ~]# service mysqld start
Starting MySQL... [ OK ]
[root@localhost ~]# netstat -tlnp|grep mysql
tcp 0 0 :::3306 :::* LISTEN 2790/mysqld
[root@localhost ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.25 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.02 sec)
mysql>
4 下面还是想起前提apache httpd的安装了,里面有socket,有pidfile文件
所以这里继续尝试,因为主配置文件有sock设置,所以请自己创建相应的文件夹,并重启服务按道理在那个文件夹就会有相应的sock文件了
就是始终找不到pidfile文件,其实我忽略了刚开始创建的数据文件夹/data/mysql,如果想知道这个也很简单
网上的一个很好的命令
[root@localhost mysqld]# ps ax|grep mysqld
4172 pts/0 S 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/localhost.localdomain.pid
4390 pts/0 Sl 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/localhost.localdomain.err --pid-file=/data/mysql/localhost.localdomain.pid --socket=/var/run/mysql/mysqld.socket --port=3306
4420 pts/0 S+ 0:00 grep mysqld
原文地址:http://qixue.blog.51cto.com/7213178/1659351