mysql编译安装

1,安装依赖软件包,包括gcc 安装工具cmake等
  yum install -y gcc make cmake ncurses-devel libxm12-devel libtool-ltdl-devel gcc-c++ autoconf automake bison zlib-devel
——————————————————————————————
2,下载安装包
安装包可在官网下载:官网地址(源码软件)
版本5.7  http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.10.tar.gz
——————————————————————————————
版本5.6  http://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.28.tar.gz
——————————————————————————————
版本5.5  http://cdn.mysql.com//Downloads/MySQL-5.5/mysql-5.5.47.tar.gz
——————————————————————————————
3,创建用户和组且为不可登录系统用户
groupadd mysql
useradd -r -s /sbin/nologin -g mysql mysql
——————————————————————————————
4,解压缩
tar -zxvf mysql-5.6.28 -C /usr/src/
——————————————————————————————
5,安装
cmake . -DENABLE_DOWNLOADS=1
make && make install


——————————————————————————————
6,为软件主目录设置用户及组
chown -R mysql.mysql /usr/local/mysql
——————————————————————————————
7,定义mysql数据库账户名称,软件主目录,数据库存放位置,
/usr/local/mysql/scripts/mysql_install_db 
--user=mysql ->定义mysql用户 
--basedir==/usr/local/mysql/ ->定义软件主目录 
--datadir=/usr/local/mysql/data ->定义数据目录
——————————————————————————-————
8,将配置文件拷贝到/etc/下
cp /usr/local/mysql/my.cnf  /etc/my.cnf
———————————————————————————————
9,启动mysql
可以将mysql软件包提供的启动脚本放置到init.d下
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
配置环境变量
将export PATH=$PATH:/usr/local/mysql/bin加到/etc/profile
_____________________________________________________________
也可以使用手动启动数据库进程 
/usr/local/mysql/bin/mysql-safe --user=mysql &
———————————————————————————————
10,相关报错处理
设置密码报错:[root@master ~]# mysqladmin -u root password 'liaoxz'


mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
____________________________________________________________
解决办法:设置//var/lib/mysql属主属组,更改/etc/my.cnf文件,指定socket位置

你可能感兴趣的:(mysql编译安装)