文档课题:rhel 6.5以编译方式安装mysql 5.5.18
数据库:mysql 5.5.18
系统:rhel 6.5 64位
安装包:mysql-5.5.18.tar.gz
1、卸载MariaDB
--卸载系统自带的mysql和mariadb-lib.
[root@MySQL5518-Master ~]# rpm -qa | grep mysql
mysql-libs-5.1.71-1.el6.x86_64
[root@MySQL5518-Master ~]# rpm -qa | grep mariadb
[root@MySQL5518-Master ~]# /bin/rpm -e $(/bin/rpm -qa | grep mysql|xargs) --nodeps
2、安装依赖包
[root@MySQL5518-Master ~]# mount /dev/sr0 /mnt
[root@MySQL5518-Master ~]# mkdir -p /etc/yum.repos.d/bak
[root@MySQL5518-Master ~]# mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak
[root@MySQL5518-Master ~]# cat <<EOF>>/etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///mnt
gpgcheck=0
enabled=1
EOF
[root@MySQL5518-Master ~]# yum makecache
[root@MySQL5518-Master ~]# yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel \
freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel \
glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel \
curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel \
libidn libidn-devel openssl openssl-devel \
openldap openldap-devel nss_ldap \
openldap-clients openldap-servers
--检查依赖包的安装情况
[root@MySQL5518-Master ~]# rpm -q gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel \
freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel \
glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel \
curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel \
libidn libidn-devel openssl openssl-devel \
openldap openldap-devel nss_ldap \
openldap-clients openldap-servers | grep "not installed"
以下包未安装成功:
package libjpeg is not installed
package libjpeg-devel is not installed
package curl-devel is not installed
package krb5 is not installed
package nss_ldap is not installed
3、安装cmake
--上传cmake
sftp> lcd F:\package
sftp> put cmake-2.8.4.tar.gz
--安装cmake
[root@MySQL5518-Master ~]# tar -zxf cmake-2.8.4.tar.gz
[root@MySQL5518-Master cmake-2.8.4]# pwd
/root/cmake-2.8.4
[root@MySQL5518-Master cmake-2.8.4]# ./configure
[root@MySQL5518-Master cmake-2.8.4]# make
[root@MySQL5518-Master cmake-2.8.4]# make install
4、建用户及组
[root@MySQL5518-Master ~]# groupadd mysql
[root@MySQL5518-Master ~]# useradd -g mysql mysql
5、安装包处理
5.1、上传安装包
sftp> lcd F:\installmedium\mysql\MySQL-5.5.18
sftp> put mysql-5.5.18.tar.gz
5.2、解压安装包
[root@MySQL5518-Master ~]# tar -zxf mysql-5.5.18.tar.gz
[root@MySQL5518-Master ~]# cd mysql-5.5.18
5.3、开始编译
[root@MySQL5518-Master ~]# /usr/local/bin/cmake -DCMAKE_INSTALL_PREFIX=/usr/local/webserver/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk,gb2312 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/var/mysql/data \
-DMYSQL_USER=mysql -DWITH_DEBUG=0
[root@MySQL5518-Master mysql-5.5.18]# make && make install
[root@MySQL5518-Master mysql-5.5.18]# chmod +w /usr/local/webserver/mysql
[root@MySQL5518-Master mysql-5.5.18]# chown -R mysql:mysql /usr/local/webserver/mysql
[root@MySQL5518-Master mysql-5.5.18]# cp support-files/my-small.cnf /etc/my.cnf
[root@MySQL5518-Master mysql-5.5.18]# chown mysql:mysql /etc/my.cnf
[root@MySQL5518-Master mysql-5.5.18]# cp /root/mysql-5.5.18/support-files/mysql.server /etc/rc.d/init.d/mysqld
6、开始安装
[root@MySQL5518-Master mysql-5.5.18]# /usr/local/webserver/mysql/scripts/mysql_install_db \
--user=mysql \
--basedir=/usr/local/webserver/mysql \
--datadir=/var/mysql/data
7、安装后配置
7.1、修改文件
[root@MySQL5518-Master ~]# vi /etc/init.d/mysqld
#按以下变量内容修改
basedir=/usr/local/webserver/mysql
datadir=/var/mysql/data
[root@MySQL5518-Master ~]# chmod +x /etc/init.d/mysqld
[root@MySQL5518-Master ~]# vi /etc/my.cnf
[mysqld]下添加如下,InnoDB配置以减少内存.
default-storage-engine=MyISAM
server-id = 1
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 2M
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
basedir=/usr/local/webserver/mysql
datadir=/var/mysql/data
[root@MySQL5518-Master ~]# mkdir -p /usr/local/mysql
[root@MySQL5518-Master ~]# cd /usr/local
[root@MySQL5518-Master local]# chown -R mysql:mysql mysql
7.2、设置开机自启
--增加mysqld服务
[root@MySQL5518-Master ~]# chkconfig --add mysqld
--设定mysqld在等级3、4、5为开启运行服务.
[root@MySQL5518-Master ~]# chkconfig --level 345 mysqld on
[root@MySQL5518-Master ~]# chkconfig --list | grep mysql
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@MySQL5518-Master local]# service mysqld start
Starting MySQL.. [ OK ]
[root@MySQL5518-Master local]# ps -ef|grep mysql
root 4363 1 0 10:28 pts/1 00:00:00 /bin/sh /usr/local/webserver/mysql/bin/mysqld_safe --datadir=/var/mysql/data --pid-file=/var/mysql/data/MySQL5518-Master.pid
mysql 4782 4363 0 10:28 pts/1 00:00:00 /usr/local/webserver/mysql/bin/mysqld --basedir=/usr/local/webserver/mysql --datadir=/var/mysql/data --plugin-dir=/usr/local/webserver/mysql/lib/plugin --user=mysql --log-error=/var/mysql/data/MySQL5518-Master.err --pid-file=/var/mysql/data/MySQL5518-Master.pid --socket=/tmp/mysql.sock --port=3306
root 4807 2488 0 10:28 pts/1 00:00:00 grep mysql
8、修改密码
[root@MySQL5518-Master ~]# /usr/local/webserver/mysql/bin/mysqladmin -u root password mysql_4U
[mysql@MySQL5518-Master bin]$ pwd
/usr/local/webserver/mysql/bin
[mysql@MySQL5518-Master bin]$ ./mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.18 Source distribution
Copyright (c) 2000, 2011, 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 |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
9、重启验证
--重启系统后mysql数据库自动开启.
[root@MySQL5518-Master mysql]# reboot
Broadcast message from root@MySQL5518-Master
(/dev/pts/1) at 11:57 ...
The system is going down for reboot NOW!
[root@MySQL5518-Master mysql]#
Last login: Fri Aug 18 23:26:01 2023 from 192.168.133.1
[root@MySQL5518-Master ~]# ps -ef | grep mysql
root 1724 1 0 11:58 ? 00:00:00 /bin/sh /usr/local/webserver/mysql/bin/mysqld_safe --datadir=/var/mysql/data --pid-file=/var/mysql/data/MySQL5518-Master.pid
mysql 2143 1724 0 11:58 ? 00:00:00 /usr/local/webserver/mysql/bin/mysqld --basedir=/usr/local/webserver/mysql --datadir=/var/mysql/data --plugin-dir=/usr/local/webserver/mysql/lib/plugin --user=mysql --log-error=/var/mysql/data/MySQL5518-Master.err --pid-file=/var/mysql/data/MySQL5518-Master.pid --socket=/tmp/mysql.sock --port=3306
root 2471 2451 0 12:00 pts/0 00:00:00 grep mysql
参考网址:https://www.cnblogs.com/fangbo/archive/2011/04/01/2002637.html
标签:5.5,--,18,devel,6.5,Master,mysql,root,MySQL5518
From: https://blog.51cto.com/u_12991611/7148869