centos6 源码安装mysql

源码安装mysql

mysql应该都清楚 这里就不多做解释 下面直接开始源码安装 这个版本是5.6.38

1.查看原来系统上是否已经安装,如果安装请卸载掉

[root@localhost ~]# rpm -qa | grep mysql
qt-mysql-4.6.2-26.el6_4.x86_64
mysql-libs-5.1.71-1.el6.x86_64
mysql-server-5.1.71-1.el6.x86_64
mysql-5.1.71-1.el6.x86_64
[root@localhost ~]# rpm -e mysql-5.1.71-1.el6.x86_64 --nodeps
[root@localhost ~]# rpm -e mysql-server-5.1.71-1.el6.x86_64 --nodeps

2.安装依赖环境

[root@localhost ~]# yum -y install gcc gcc-c++ bison ncurses  ncurses-devel boost cmake

3.新建用户

[root@localhost ~]# useradd  mysql

4.解压、配置、编译、安装

[root@localhost ~]# tar zxf mysql-5.6.38.tar.gz
[root@localhost ~]# cd mysql-5.6.38
[root@localhost mysql-5.6.38]# cmake  .
[root@localhost mysql-5.6.38]# make && make install
  • 做完这一步就可以喝杯咖啡啦 时间有点长 第四中的第三步cmake后面有一个点别忘了 否则会报错

5.初始化、做主配置文件、自带脚本启动

  • 初始化
[root@localhost mysql-5.6.38]#  /usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/ --basedir=/usr/local/mysql/
  • 做主配置文件
[root@localhost mysql-5.6.38]# cp /usr/local/mysql/support-files/my-default.cnf  /etc/my.cnf 
cp:是否覆盖"/etc/my.cnf"? yes
  • 启动
[root@localhost mysql-5.6.38]# /usr/local/mysql/support-files/mysql.server start

6.做软连接、启动项

[root@localhost mysql-5.6.38]# ln -s /usr/local/mysql/bin/* /usr/local/bin/

7.查看是否成功启动

[root@localhost mysql-5.6.38]# ps -ef | grep mysqld

8.测试能否登陆

  • 5.7以下版本默认情况下root用户没有密码,可以直接登录
[root@localhost mysql-5.6.38]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.38 Source distribution

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

上一篇:75.iptables 之centos6系列(day75)


下一篇:CentOS6启动流程(含详细流程图)