1.假设已经有mysql-5.5.10.tar.gz以及cmake-2.8.4.tar.gz两个源文件

(1)先安装cmake(mysql5.5以后是通过cmake来编译的)

  1. [root@ rhel5 local]#tar -zxv -f cmake-2.8.4.tar.gz
    [root@ rhel5 local]#cd cmake-2.8.4
    [root@ rhel5 cmake-2.8.4]#./configure
    [root@ rhel5 cmake-2.8.4]#make
    [root@ rhel5 cmake-2.8.4]#make install

(2)创建mysql的安装目录及数据库存放目录

  1. [root@ rhel5~]#mkdir -p /usr/local/mysql //安装mysql
    [root@ rhel5~]#mkdir -p /usr/local/mysql/data //存放数据库

(3)创建mysql用户及用户组

  1. [root@ rhel5~]groupadd mysql
    [root@ rhel5~]useradd -r -g mysql mysql

(4)安装mysql

  1. [root@ rhel5 local]#tar -zxv -f mysql-5.5.10.tar.gz
    [root@ rhel5 local]#cd mysql-5.5.10
    [root@ rhel5 mysql-5.5.10]#cmake .
    -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
    -DMYSQL_DATADIR=/usr/local/mysql/data
    -DDEFAULT_CHARSET=utf8
    -DDEFAULT_COLLATION=utf8_general_ci
  1. -DEXTRA_CHARSETS=all
    -DENABLED_LOCAL_INFILE=1
    [root@ rhel5 mysql-5.5.10]#make
    [root@ rhel5 mysql-5.5.10]#make install

参数说明:

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql        //安装目录

-DINSTALL_DATADIR=/usr/local/mysql/data         //数据库存放目录

-DDEFAULT_CHARSET=utf8                        //使用utf8字符

-DDEFAULT_COLLATION=utf8_general_ci            //校验字符

-DEXTRA_CHARSETS=all                            //安装所有扩展字符集

-DENABLED_LOCAL_INFILE=1                        //允许从本地导入数据

注意事项:

重新编译时,需要清除旧的对象文件和缓存信息。

# make clean

# rm -f CMakeCache.txt

# rm -rf /etc/my.cnf

2.配置

(1)设置目录权限

  1. [root@ rhel5~]# cd /usr/local/mysql
  2.  
  3. [root@ rhel5 mysql]# chown -R root:mysql . //把当前目录中所有文件的所有者所有者设为root,所属组为mysql
  4.  
  5. [root@ rhel5 mysql]# chown -R mysql:mysql data

(2)

  1. [root@ rhel5 mysql]# cp support-files/my-medium.cnf /etc/my.cnf //将mysql的启动服务添加到系统服务中

(3)创建系统数据库的表

  1. [root@ rhel5 mysql]# cd /usr/local/mysql
    [root@ rhel5 mysql]# scripts/mysql_install_db --user=mysql

(4)设置环境变量

  1. [root@ rhel5~]# vi /root/.bash_profile
  2.  
  3. PATH=$PATH:$HOME/bin添加参数为:
  4.  
  5. PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib
  6.  
  7. [root@ rhel5~]#source /root/.bash_profile

(5)手动启动mysql

  1. [root@ rhel5~]# cd /usr/local/mysql
  2.  
  3. [root@ rhel5 mysql]# ./bin/mysqld_safe --user=mysql &   //启动MySQL,但不能停止
  4.  
  5. 启动日志写在此文件下:/usr/local/mysql/data/localhost.err
  6.  
  7. 关闭MySQL服务
  8.  
  9. [root@ rhel5 mysql]# mysqladmin -u root -p shutdown  //这里MySQL的root用户还没有配置密码,所以为空值。需要输入密码时,直接点回车键即可。

(6)另一种简单的启动mysql的方法(mysql已经被添加到系统服务中)

  1. [root@ rhel5~]# service mysql.server start
    [root@ rhel5~]# service mysql.server stop
    [root@ rhel5~]# service mysql.server restart

如果上述命令出现:mysql.server 未识别的服务

则可能mysql还没添加到系统服务中,下面用另一种方法添加:

  1. [root@ rhel5 mysql]# cp support-files/mysql.server /etc/init.d/mysql //将mysql的启动服务添加到系统服务中

注意:主要是将mysql.server拷贝到/etc/init.d中,命名为mysql。在有的系统中,mysql.server在/usr/local/mysql/share/mysql/mysql.server中,而本系统中,mysql.server在/usr/local/mysql/support-files/mysql.server中。

然后再用#service mysql start 来启动mysql即可。

(7)修改MySQL的root用户的密码以及打开远程连接

  1. [root@ rhel5~]# mysql -u root mysql
  2.  
  3. mysql>use mysql;
    mysql>desc user;
    mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root";  //为root添加远程连接的能力。
    mysql>update user set Password = password('xxxxxx') where User='root';
    mysql>select Host,User,Password from user where User='root';
    mysql>flush privileges;
    mysql>exit
  4.  
  5. 重新登录:mysql -u root -p
  6.  
  7. 若还不能进行远程连接,则关闭防火墙
    [root@ rhel5~]# /etc/rc.d/init.d/iptables stop

注:如果不能远程连接,出现错误mysql error number 1130,则加入下面语句试试:

mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '******' WITH GRANT OPTION;

Linux安装mysql——源码安装的更多相关文章

  1. linux下mysql源码安装

    参考链接:http://blog.csdn.net/zqtsx/article/details/9378703 下载mysql安装包, 不会下载点这里 地址:ftp://mirror.switch.c ...

  2. Linux平台下源码安装mysql多实例数据库

    Linux平台下源码安装mysql多实例数据库[root@linux-node1 ~]# netstat -tlunp | grep 330tcp6 0 0 :::3306 :::* LISTEN 6 ...

  3. Linux(CentOS或RadHat)下MySQL源码安装

    安装环境: CentOS6.3 64位 软件: Mysql-5.6 所需包: gcc/g++ :MySQL 5.6开始,需要使用g++进行编译.cmake  :MySQL 5.5开始,使用cmake进 ...

  4. maridb\mysql 源码安装,以10.1.26版本为例

    mysql 源码安装(mariadb 10.1.26) 1.环境部署 1 安装cmake 源码安装三部曲或者yum install cmake2安装依赖包yum install -y ncurses- ...

  5. Linux MySQL源码安装缺少ncurses-devel包

    在Red Hat Enterprise Linux Server release 5.7 上用源码安装MySQL-5.6.23时,遇到了" remove CMakeCache.txt and ...

  6. Linux 环境编译安装mysql (源码安装包)

    标注: Linux需要先配置网络yum源,确定yum能在线安装软件包,方便测试过程中安装部分依赖包.配置163网易提示的网络yum源参考博客  http://www.cnblogs.com/zoulo ...

  7. Linux 中mysql安装(源码安装方式)

    本文是介绍以源码安装的方式编译和安装Mysql 5.6(可以指定安装路径),也可以不采用源码安装方式,直接用安装包的方式. 源码安装方式慎用,容易报错. 1.卸载旧版本 rpm -qa | grep ...

  8. 【转】Ubuntu编译安装mysql源码

    主要参考了下面两篇文章 http://forum.ubuntu.org.cn/viewtopic.php?t=330121 http://www.linuxidc.com/Linux/2011-09/ ...

  9. Linux 6.8 源码安装MySQL8.0

    搭建环境说明: 系统版本:Red Hat Enterprise Linux Server release 6.8 (Santiago) 内核版本:Linux 2.6.32-642.el6.x86_64 ...

随机推荐

  1. githug-54-git练习

    1-40: http://wiki.jikexueyuan.com/project/git-54-stage-clear/ 41-50: https://blog.csdn.net/maxam0128 ...

  2. springboot h2数据库的配置

    配置文件 #h2 数据库配置 #配置数据库连接地址spring.datasource.url=jdbc:h2:sunniwell:sos#配置数据库驱动spring.datasource.driver ...

  3. HTML代码 CSS

    第一步.编写横向菜单的HTML代码架构 请将以下代码添加到HTML文档的导航栏区域中. <ul id="menu"> <li><a href=&quo ...

  4. [Node.js] Level 2 new. Event

    Chat Emitter We're going to create a custom chat EventEmitter. Create a new EventEmitter object and ...

  5. 如何用7-zip创建自解压文件,7Z软件如何使用

    1 要创建自解压文件,一般都是双击直接解压到C盘的Program Files文件夹里面,或许还需要在桌面创建一个快捷方式之类的.但是一般的绿色软件除了复制到Program Files还需要运行一下绿化 ...

  6. CDN具体解释(篇一)

    CDN是一个致力于使内容传输更快.更高效的针对webserver的全局分布式网络.通过CDN来复制使这些内容能够在非常多地方同一时候存在. 比較有名的CDN厂商有AKamari,Amazon Clou ...

  7. NSURLSession 学习笔记

    NSURLSession 学习笔记 一:NSURLSession 类似之前的NSURLConnection, 可配置每个session的 cookie,证书等网络连接配置信息 NSURLSession ...

  8. win10系统80端口被占用怎么办?

    win10系统80端口被占用怎么办? 因为win10默认开启了IIS因此占用了80端口,可以netstat –ano 查到. 运行netstat -aon | findstr :80 ,发现pid是4 ...

  9. 【Accountancy】资产

    1. 资产定义 资产是指企业过去的交易或事项形成的.由企业拥有或控制的.预期会给企业带来经济利益的资源. 2. 资产分类 2.1 货币资金 概念 货币资金是指企业生产经营过程中处于货币形态的资产,包括 ...

  10. glob 模块

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #glob 模块 #http://python.jobbole.com/81552/ #查找文件只用到三个匹配 ...