標籤:mysql 5.1.72安裝
安裝mysql之前 我想告訴你
在Linux核心當中運行一個進程 一定是以某使用者的身份進行啟動並執行
今天 Mysql就是如此 不管 以後是什麼服務 都是一樣的......
運行環境如下: 非常純淨的系統 什麼都沒有安裝
CentOS 6.4
mysql-5.1.72
檢查結果:
[[email protected] tools]# cat /etc/redhat-release CentOS release 6.4 (Final)[[email protected] tools]# uname -r2.6.32-358.el6.x86_64[[email protected] tools]# ifconfig eth0eth0 Link encap:Ethernet HWaddr 00:0C:29:2F:59:28 inet addr:172.16.30.11 Bcast:172.16.255.255 Mask:255.255.0.0 inet6 addr: fe80::20c:29ff:fe2f:5928/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric: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)[[email protected] tools]# hostname LAMP
1.添加一個系統使用者 不建立家目錄 不允許使用者登入 只是使用者運行 mysql這個進程使用
[[email protected] tools]# useradd -r -s /sbin/nologin mysql[[email protected] tools]# id mysqluid=498(mysql) gid=498(mysql) groups=498(mysql)[[email protected] tools]# tail -1 /etc/passwdmysql:x:498:498::/home/mysql:/sbin/nologin
2.解壓 mysql-5.1.72.tar.gz 軟體
[[email protected] tools]# pwd/root/tools[[email protected] tools]# lltotal 31024-rw-r--r--. 1 root root 133591 May 16 14:14 cronolog-1.6.2.tar.gz-rw-r--r--. 1 root root 7583841 Jul 17 2015 httpd-2.2.31.tar.gz-rw-r--r--. 1 root root 24044338 May 16 20:34 mysql-5.1.72.tar.gz[[email protected] tools]# 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包未安裝
650) this.width=650;" src="http://s2.51cto.com/wyfs02/M01/80/2C/wKioL1c6gQ7iJY8NAAAIZFWidJM802.png" title="02.png" alt="wKioL1c6gQ7iJY8NAAAIZFWidJM802.png" />
解決方案是採用 yum 進行安裝
yum install ncurses-devel -y
完成上面的封裝之後 再進行 ./configure配置檢查一下 就可以.....
650) this.width=650;" src="http://s2.51cto.com/wyfs02/M00/80/2F/wKiom1c6gVHynuNHAAANaP6UkJY910.png" title="03.png" alt="wKiom1c6gVHynuNHAAANaP6UkJY910.png" />
4.編譯 並進行安裝
[[email protected] mysql-5.1.72]# echo $? //列印上一條命令是否有錯誤 0代表成功0[[email protected] mysql-5.1.72]# make && make install //編譯 並 安裝
****************************************************************************
下面進行初始化配置 MySQL資料
****************************************************************************
5.把來源程式目錄下面
[[email protected] mysql-5.1.72]# pwd/root/tools/mysql-5.1.72[[email protected] mysql-5.1.72]# \cp support-files/my-small.cnf /etc/my.cnf
6.建立一個軟連結
[[email protected] mysql-5.1.72]# ln -s /application/mysql5.1.72/ /application/mysql
7.建立一個目錄存放資料庫檔案
[[email protected] mysql-5.1.72]# mkdir /application/mysql/data -p[[email protected] mysql-5.1.72]# ll -ld /application/mysql/data/drwxr-xr-x. 2 root root 4096 May 17 18:42 /application/mysql/data/
8.修改 /application/mysql 目錄許可權 因為我們要指定使用者 mysql初始化
所以 mysql得要有所有管理權
[[email protected] mysql-5.1.72]# 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
做為系統服務啟動
[[email protected] support-files]# pwd/root/tools/mysql-5.1.72/support-files[[email protected] support-files]# cp mysql.server /etc/init.d/mysqld[[email protected] support-files]# [[email protected] support-files]# chmod a+x /etc/init.d/mysqld
11.出於安全考慮 我們應該把 /application/mysql 的許可權還給 root
再把 /application/mysql/data 這個目錄設定成 mysql管理權
[[email protected] support-files]# chown -R root:root /application/mysql[[email protected] support-files]# chown -R mysql:mysql /application/mysql/data/
12.啟動吧.........
[[email protected] ~]# /etc/init.d/mysqld startStarting MySQL. SUCCESS! [[email protected] ~]# lsof -i:3306COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEmysqld 19223 mysql 10u IPv4 103134 0t0 TCP *:mysql (LISTEN)
13.後續工作
將 /etc/init.d/mysql start 開機自啟動
將 /application/mysql/bin 放到環境變數當中去
[[email protected] ~]# echo "/etc/init.d/mysql start" >> /etc/rc.local [[email protected] ~]# cd /etc/profile.d/[[email protected] profile.d]# touch mysql.sh[[email protected] profile.d]# vi mysql.sh
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/80/2C/wKioL1c6isKS6c0dAAAD5hy9okI750.png" title="04.png" alt="wKioL1c6isKS6c0dAAAD5hy9okI750.png" />
[[email protected] profile.d]# source mysql.sh 讓mysql.sh裡面的環境變數生效
14.測試一下
[[email protected] ~]# mysql //直接在命令列敲 mysql就可以進入管理....Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.1.72 Source distributionCopyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.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
MySQL 5.1.72安裝