zoukankan      html  css  js  c++  java
  • centos6.5下编译安装单实例MySQL5.1

    MySQL5.1版本安装3步曲:

    1)   ./config 指定编译安装参数
    2)   make
    3)   make install

    查看系统版本号

    [root@meinv01 ~]# cat /etc/redhat-release
    [root@meinv01 ~]# uname -m
    [root@meinv01 ~]# uname -r

    解压MySQL包

    [root@meinv01 tools]# tar xf mysql-5.1.72.tar.gz

    建立MySQL账户

    [root@meinv01 tools]# groupadd -g 49 mysql
    [root@meinv01 tools]# useradd mysql -u 49 -g 49 -M -s /sbin/nologin
    [root@meinv01 tools]# id mysql
    uid=49(mysql) gid=49(mysql) groups=49(mysql)

    安装依赖包

    [root@meinv01 mysql-5.1.72]# yum install ncurses-devel -y

    编译安装MySQL5.1

    [root@meinv01 tools]# cd mysql-5.1.72
    [root@meinv01 tools]# ./configure 
    --prefix=/application/mysql5.1.72 
    --with-unix-socket-path=/application/mysql5.1.72/tmp/mysql.sock 
    --localstatedir=/application/mysql5.1.72/data 
    --enable-assembler 
    --enable-thread-safe-client 
    --with-mysql-user=mysql 
    --with-big-tables 
    --without-debug 
    --with-pthread 
    --enable-assembler 
    --with-extra-charsets=complex 
    --with-readline 
    --with-ssl 
    --with-embedded-server 
    --enable-local-infile 
    --with-plugins=partition,innobase 
    --with-mysqld-ldflags=-all-static 
    --with-client-ldflags=-all-static 
    [root@meinv01 mysql-5.1.72]# echo $?
    0
    [root@meinv01 mysql-5.1.72]# make && make install

    创建软链接和添加hosts解析

    [root@meinv01 mysql-5.1.72]# ln -s /application/mysql5.1.72/ /application/mysql
    [root@meinv01 mysql-5.1.72]# ll /application/mysql
    lrwxrwxrwx 1 root root 25 Oct 23 13:15 /application/mysql -> /application/mysql5.1.72/
    [root@meinv01 support-files]# vi /etc/hosts          #添加本机主机名至hosts中

    创建存放MySQL数据库的目录并授权

    [root@meinv01 support-files]# mkdir /application/mysql/data -p            #授权MySQL管理目录权限
    [root@meinv01 support-files]# chown -R mysql.mysql /application/mysql/       #创建MySQL初始化的文件
    [root@meinv01 support-files]# chmod 1777 /tmp

    初始化MySQL数据库

    [root@meinv01 support-files]# cp my-small.cnf /etc/my.cnf     #实验环境选择小的配置文件
    [root@meinv01 support-files]# /application/mysql/bin/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data/ --user=mysql  

    添加PATH环境变量

    [root@meinv01 support-files]# echo "PATH="/application/mysql/bin:$PATH"" >>/etc/profile
    [root@meinv01 support-files]# tail -1 /etc/profile
    PATH=/application/mysql/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
    [root@meinv01 support-files]# . /etc/profile           #立刻生效

    添加MySQL至开机自启动

    [root@meinv01 support-files]# cp mysql.server /etc/init.d/mysqld  #直接拷贝到/etc/init.d/
    [root@meinv01 support-files]# chmod +x /etc/init.d/mysqld 
    [root@meinv01 support-files]# chkconfig --add mysqld               #添加到chkconfig开机自启动
    [root@meinv01 support-files]# chkconfig --level 3 mysqld on            #开机自启动
    [root@meinv01 support-files]# /etc/init.d/mysqld                      #如果此步没有出现以下参数,就要先授权x权限
    Usage: /etc/init.d/mysqld  {start|stop|restart|reload|force-reload|status}  [ MySQL server options ]
    [root@meinv01 support-files]# /etc/init.d/mysqld start                                           #启动MySQL服务
    [root@meinv01 support-files]# lsof -i :3306

    MySQL数据库2种启动方式

    第一种:
    [root@meinv01 support-files]# /etc/init.d/mysqld start                       #启动MySQL服务
    第二种:
    [root@meinv01 support-files]# /application/mysql/bin/mysqld_safe &        #启动MySQL服务
    注意:最好不要混合使用,混合使用有可能报错,虽然本质上是一样的启动方法
    [root@meinv01 mysql-5.1.72]# ps -ef|grep mysqld  #查看启动相关信息
    root      1035     1  0 17:47 pts/0    00:00:00 /bin/sh /application/mysql5.1.72/bin/mysqld_safe --datadir=/application/mysql5.1.72/data --pid-file=/application/mysql5.1.72/data/meinv01.pid
    mysql     1147  1035  0 17:47 pts/0    00:00:00 /application/mysql5.1.72/libexec/mysqld --basedir=/application/mysql5.1.72 --datadir=/application/mysql5.1.72/data --user=mysql --log-error=/application/mysql5.1.72/data/meinv01.err --pid-file=/application/mysql5.1.72/data/meinv01.pid --socket=/application/mysql5.1.72/tmp/mysql.sock --port=3306
    root      1169   951  0 17:52 pts/0    00:00:00 grep --color=auto mysqld

    修改MySQL登录密码

    /application/mysql/bin/mysqladmin -u root password 'new-password'       #设置密码的方法
    

     

     

  • 相关阅读:
    【SICP练习】63 练习2.34
    【SICP练习】62 练习2.33
    【SICP练习】61 练习2.31-2.32
    【SICP练习】60 练习2.30
    【SICP练习】59 练习2.29
    【SICP练习】58 练习2.28
    【SICP练习】57 练习2.27
    【SICP练习】56 练习2.24-2.26
    【SICP练习】55 练习2.23
    【SICP练习】54 练习2.22
  • 原文地址:https://www.cnblogs.com/blog-tim/p/10104252.html
Copyright © 2011-2022 走看看