yunde110 发表于 2018-10-1 12:28:52

MySQL 5.1.72安装

  安装mysql之前 我想告诉你
  在Linux内核当中运行一个进程一定是以某用户的身份进行运行的
  今天 Mysql就是如此不管 以后是什么服务都是一样的......
  运行环境如下:非常纯净的系统什么都没有安装
  CentOS 6.4
  mysql-5.1.72
  检查结果:
# cat /etc/redhat-release  
CentOS release 6.4 (Final)
  
# uname -r
  
2.6.32-358.el6.x86_64
  
# ifconfig eth0
  
eth0      Link encap:EthernetHWaddr 00:0C:29:2F:59:28
  
          inet addr:172.16.30.11Bcast:172.16.255.255Mask:255.255.0.0
  
          inet6 addr: fe80::20c:29ff:fe2f:5928/64 Scope:Link
  
          UP BROADCAST RUNNING MULTICASTMTU:1500Metric:1
  
          RX packets:368 errors:0 dropped:0 overruns:0 frame:0
  
          TX packets:277 errors:0 dropped:0 overruns:0 carrier:0
  
          collisions:0 txqueuelen:1000
  
          RX bytes:34526 (33.7 KiB)TX bytes:37299 (36.4 KiB)
  

  
# hostname
  
LAMP
  1.添加一个系统用户 不创建家目录 不允许用户登录 只是用户运行 mysql这个进程使用
# useradd -r -s /sbin/nologin mysql  
# id mysql
  
uid=498(mysql) gid=498(mysql) groups=498(mysql)
  
# tail -1 /etc/passwd
  
mysql:x:498:498::/home/mysql:/sbin/nologin
  2.解压 mysql-5.1.72.tar.gz 软件
# pwd  
/root/tools
  
# ll
  
total 31024
  
-rw-r--r--. 1 root root   133591 May 16 14:14 cronolog-1.6.2.tar.gz
  
-rw-r--r--. 1 root root7583841 Jul 172015 httpd-2.2.31.tar.gz
  
-rw-r--r--. 1 root root 24044338 May 16 20:34 mysql-5.1.72.tar.gz
  
# tar xf mysql-5.1.72.tar.gz
  3.检查配置
  ./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-mysqld-user=mysql \
  --with-big-tables \
  --without-debug \
  --with-pthread \
  --with-extra-charsets=complex \
  --with-readline \
  --with-ssl \
  --with-embedded-server \
  --with-local-infile \
  --with-plugins=partition,innobase \
  --with-mysqld-ldflags=-all-static \
  --with-client-ldflags=-all-static
./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-mysqld-user=mysql \
  
--with-big-tables \
  
--without-debug \
  
--with-pthread \
  
--with-extra-charsets=complex \
  
--with-readline \
  
--with-ssl \
  
--with-embedded-server \
  
--with-local-infile \
  
--with-plugins=partition,innobase \
  
--with-mysqld-ldflags=-all-static \
  
--with-client-ldflags=-all-static
  可能会遇到的问题 curses包未安装

  解决方案是采用 yum 进行安装
yum install ncurses-devel -y  完成上面的包装之后 再进行 ./configure配置检查一下 就可以.....

  4.编译 并进行安装
# echo $?   //打印上一条命令是否有错误 0代表成功  
0
  
# make && make install   //编译 并 安装
  ****************************************************************************
  下面进行初始化配置 MySQL数据
  ****************************************************************************
  5.把源程序目录下面
# pwd  
/root/tools/mysql-5.1.72
  
# \cp support-files/my-small.cnf /etc/my.cnf
  6.创建一个软链接
# ln -s /application/mysql5.1.72/ /application/mysql  7.创建一个目录存放数据库文件
# mkdir /application/mysql/data -p  
# ll -ld /application/mysql/data/
  
drwxr-xr-x. 2 root root 4096 May 17 18:42 /application/mysql/data/
  8.修改 /application/mysql 目录权限 因为我们要指定用户 mysql初始化
  所以 mysql得要有所有管理权
# chown -R mysql:mysql /application/mysql  9.进入初始化
  /application/mysql/bin/mysql_install_db \
  --basedir=/application/mysql \
  --datadir=/application/mysql/data \
  --user=mysql
/application/mysql/bin/mysql_install_db \  
--basedir=/application/mysql \
  
--datadir=/application/mysql/data \
  
--user=mysql
  10.将support-files/mysql.server文件复制到 /etc/init.d/mysqld
  做为系统服务启动
# pwd  
/root/tools/mysql-5.1.72/support-files
  
# cp mysql.server /etc/init.d/mysqld
  
#
  
# chmod a+x /etc/init.d/mysqld
  11.出于安全考虑 我们应该把 /application/mysql 的权限还给 root
  再把 /application/mysql/data 这个目录设置成 mysql管理权
# chown -R root:root /application/mysql  
# chown -R mysql:mysql /application/mysql/data/
  12.启动吧.........
# /etc/init.d/mysqld start  
Starting MySQL. SUCCESS!
  
# lsof -i:3306
  
COMMAND   PIDUSER   FD   TYPE DEVICE SIZE/OFF NODE NAME
  
mysqld19223 mysql   10uIPv4 103134      0t0TCP *:mysql (LISTEN)
  13.后续工作
  将 /etc/init.d/mysql start 开机自启动
  将 /application/mysql/bin 放到环境变量当中去
# echo "/etc/init.d/mysql start" >> /etc/rc.local  
# cd /etc/profile.d/
  
# touch mysql.sh
  
# vi mysql.sh

# source mysql.sh   让mysql.sh里面的环境变量生效  14.测试一下
# mysql   //直接在命令行敲 mysql就可以进入管理....  
Welcome to the MySQL monitor.Commands end with ; or \g.
  
Your MySQL connection id is 2
  
Server version: 5.1.72 Source distribution
  

  
Copyright (c) 2000, 2013, 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> show databases;
  
+--------------------+
  
| Database         |
  
+--------------------+
  
| information_schema |
  
| mysql            |
  
| test               |
  
+--------------------+
  
3 rows in set (0.00 sec)
  恭喜你 你已经学会安装 Mysql了
  QQ:771541213


页: [1]
查看完整版本: MySQL 5.1.72安装