美文网首页
MySQL_5.5.64 源码安装

MySQL_5.5.64 源码安装

作者: DB哥 | 来源:发表于2019-09-29 08:39 被阅读0次

Linux System Environment

[root@nginx01 ~]# cat /etc/redhat-release                   #==》系统版本
CentOS release 6.7 (Final)
[root@nginx01 ~]# uname –r                                 #==》内核版本
2.6.32-573.el6.x86_64
[root@nginx01 ~]# uname -m                                 #==》系统架构
x86_64
[root@nginx01 ~]# echo $LANG                               #==》系统字符集
en_US.UTF-8
[root@MySQL01 ~]# mysql –V                                 #==》MySQL版本
mysql Ver 14.14 Distrib 5.5.62, for Linux (x86_64) using readline 5.1
MySQL源码安装包下载地址:
https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.62.tar.gz
MD5:a2ce39730dd5a3f0a81b44b3985952e8

**CMake源码安装包下载地址:**
https://cmake.org/files/v3.0/cmake-3.0.0.tar.gz
MD5:https://cmake.org/files/v3.0/cmake-3.0.0-rc6-SHA-256.txt

MySQL官网地址:https://www.mysql.com/
CMake官网地址:https://cmake.org/

MySQL配置文件

提示:**/application/mysql是MySQL程序目录


#==》MySQL启动脚本,一般复制到**/etc/init.d/mysqld**
/application/mysql/support-files/mysql.server 

#==》MySQL主配置文件,一 般复制到**/etc/my.cnf**
/application/mysql/support-files/my-small.cnf /etc/my.cnf   

#==》MySQL所有二进制命令存放目录,可复制到/usr/local/sbin目录下或者添加环境变量
/application/mysql/bin/

#==》MySQL错误日志
/application/mysql/data/ MySQL01.err

#==》MySQL默认端口 3306
[root@mysql ~]# netstat -tlunp | grep 3306
tcp 0 0 0.0.0.0:**3306** 0.0.0.0:* LISTEN 4780/mysqld

#==》MySQL套接字文件sock
/application/mysql-5.5.32/tmp/mysql.sock

一、MySQL安装

1、配置阿里Yum源

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
yum makecache

2、下载MySQL软件包和CMake软件包

[root@MySQL01 ~]# mkdir /home/oldboy/tools/
[root@MySQL01 ~]# cd /home/oldboy/tools/
[root@MySQL01 tools]# wget https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.62.tar.gz
[root@MySQL01 tools]# wget https://cmake.org/files/v3.0/cmake-3.0.0.tar.gz
[root@MySQL01 tools]# ls -l
total 25984
-rw-r--r-- 1 root root 5489804 Jun 11 2014 cmake-3.0.0.tar.gz
-rw-r--r-- 1 root root 21111902 Aug 29 2018 mysql-5.5.62.tar.gz

3、解压并安装CMake

[root@MySQL01 tools]# tar xf cmake-3.0.0.tar.gz
[root@MySQL01 tools]# cd cmake-3.0.0
[root@MySQL01 cmake-3.0.0]# ./configure
[root@MySQL01 cmake-3.0.0]# gmake
[root@MySQL01 cmake-3.0.0]# gmake install
[root@MySQL01 cmake-3.0.0]# echo $?
0

4、yum安装ncurses依赖包

[root@MySQL01 cmake-3.0.0]# cd ..
[root@MySQL01 tools]# yum install ncurses-devel -y

5、创建mysql用户

[root@MySQL01 tools]# useradd -s /sbin/nologin -M mysql
[root@MySQL01 tools]# id mysql
uid=501(mysql) gid=501(mysql) groups=501(mysql)

6、安装编译MySQL

[root@MySQL01 tools]# tar xf mysql-5.5.62.tar.gz
[root@MySQL01 tools]#cd mysql-5.5.62

[root@MySQL01 mysql-5.5.62]#
cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.62 \
-DMYSQL_DATADIR=/application/mysql-5.5.62/data \
-DMYSQL_UNIX_ADDR=/application/mysql-5.5.62/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FAST_MUTEXES=1 \
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_DEBUG=0

[root@MySQL01 mysql-5.5.62]# make
[100%] Built target my_safe_process
[root@MySQL01 mysql-5.5.62]# make install
[root@MySQL01 mysql-5.5.62]# echo $?
0
[root@MySQL01 tools]# ln -s /application/mysql-5.5.62/ /application/mysql
[root@MySQL01 tools]#mkdir /application/mysql-5.5.62/tmp
[root@MySQL01 tools]# chmod -R mysql.mysql /application/mysql-5.5.62/tmp

7、配置PATH环境变量

标注:**/application/mysql/bin务必放在PATH环境变量最前面

[root@MySQL01 mysql-5.5.62]# cd ..
[root@MySQL01 tools]# echo 'export PATH=/application/mysql/bin:$PATH' >> /etc/profile
[root@MySQL01 tools]# tail -1 /etc/profile
export PATH=/application/mysql/bin:$PATH
[root@MySQL01 tools]# source /etc/profile
[root@MySQL01 tools]# echo $PATH
/application/mysql/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

8、MySQL数据目录授权mysql用户及用户组

[root@MySQL01 tools]# chown -R mysql.mysql /application/mysql/data/
[root@MySQL01 tools]# ls -ld /application/mysql/data/
drwxr-xr-x 5 mysql mysql 4096 Jul 23 16:21 /application/mysql/data/
[root@MySQL01 tools]# chmod -R 1777 /tmp

9、复制MySQL配置文件覆盖/etc/my.cnf

[root@MySQL01 tools]# \cp /home/oldboy/tools/mysql-5.5.62/support-files/my-small.cnf /etc/my.cnf

10、MySQL初始化

[root@MySQL01 tools]# cd /application/mysql/scripts/
[root@MySQL01 scripts]#
./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
WARNING: The host 'MySQL01' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
190723 16:21:34 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
190723 16:21:34 [Note] /application/mysql//bin/mysqld (mysqld 5.5.62) starting as process 25686 ...
OK
Filling help tables...
190723 16:21:35 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
190723 16:21:35 [Note] /application/mysql//bin/mysqld (mysqld 5.5.62) starting as process 25693 ...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/application/mysql//bin/mysqladmin -u root password 'new-password'
/application/mysql//bin/mysqladmin -u root -h MySQL01 password 'new-password'
Alternatively you can run:
/application/mysql//bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /application/mysql/ ; /application/mysql//bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /application/mysql//mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/

11、复制MySQL脚本并设置自启动

[root@MySQL01 scripts]# cp /home/oldboy/tools/mysql-5.5.62/support-files/mysql.server /etc/init.d/mysqld
[root@MySQL01 scripts]# chmod +x /etc/init.d/mysqld
[root@MySQL01 scripts]# chkconfig --add mysqld
[root@MySQL01 scripts]# chkconfig mysqld on
[root@MySQL01 scripts]# chkconfig --list mysqld
mysqld  0:off  1:off  2:on  3:on  4:on  5:on  6:off

12、MySQL设置密码

[root@MySQL01 ~]# mysqladmin -u root password '123456'
[root@MySQL01 ~]# mysql -uroot -p123456

相关文章

网友评论

      本文标题:MySQL_5.5.64 源码安装

      本文链接:https://www.haomeiwen.com/subject/xtllyctx.html