由于需要让MySQL支持Emoji表情的存储、不得不将服务器的mysql5.5升级到5.6,技术难度不大但是在安装过程中可能会有一些幺蛾子出现,特写一篇备忘录纪念整个过程,如有需要,请拿走不谢!文章若有不足之处、请联系我修正,谢谢。
一、因为mysql是在C语言下写的,因此对于mysql的源码编译需要C的环境,so安装环境支持 yum install gcc-c++

二、由于mysql5.6的编译方式已经换成cmake,点击下载cmake-2.8.5.tar.gz,上传至centos(/usr/local),并解压
# cd /usr/local
# tar -zxvf cmake-2.8.4.tar.gz
# cd cmake-2.8.4
#./configure
# make && make install
三、官方下载源码包(make sure 源码包非安装包,我用的 mysql-5.6.35.tar.gz),同样下载后上传至 centos(/usr/local)并解压
# cd /usr/local
# tar -zxvf mysql-5.6.35.tar.gz
# cd mysql-5.6.35
# 这里先设置cmake编译的参数,通常设置安装路径避免安装目录和源码目录混在一起
# cmake -DCMAKE_INSTALL_PREFI X=/usr/localhost/mysql-install
/* 这里可能会报错[!!!不报错,请跳过]*/
CMake Error at cmake/readline.cmake:85 (MESSAGE):Curses library not found. Please install
appropriate package(此处省略1w零1个字);
剖析:初中英语水平应该也能看懂大概就是没有找到library少包了,不用百度了,就是他ncurses-devel
# yum install ncurses-devel.x86_64 -y
# find / -name CMakeCache.txt
# rm -rf /usr/local/src/cmake-2.8.8/Tests/Complex/Cache/CMakeCache.txt
# rm -rf /usr/local/src/cmake-2.8.8/Tests/ComplexOneConfig/Cache/CMakeCache.txt
# rm -rf /usr/local/src/cmake-2.8.8/Tests/ComplexRelativePaths/Cache/CMakeCache.txt
# rm -rf /usr/local/src/mysql-5.6.25/CMakeCache.txt
# cmake -DCMAKE_INSTALL_PREFI X=/usr/localhost/mysql-install
四、编译代码啰~~~
#make
#make install clean
客官、来杆(zhi)烟~~再来一杆(zhi)~~再来一杆(zhi),好了差不多完了.
五、添加mysql用户
#useradd mysql -M -s /sbin/nologin
六、安装数据库
# cd /opt/mysql/scripts
# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql-install
--datadir=/usr/local/mysql-install/data
# 可能报错缺少Perl包[!!!不报错,请跳过]:yum install -y perl-Module-Install.noarch
# cd /opt/mysql/support-files
#复制mysql管理脚本
#cp mysql.server /etc/rc.d/init.d/mysql
#复制mysql配置文件
#cp my-default.cnf /etc/my.cnf
#添加mysql服务
#chkconfig --add mysql
七、修改MySQL相关配置项,贴出示例代码(仅供参考):
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[client]
default-character-set=utf8mb4
port=3306
socket=/tmp/mysql.sock
default-character-set=utf8mb4
host=localhost
user=root
password='root'
[mysql]
default-character-set = utf8mb4
[mysqld]
port=3306
socket=/tmp/mysql.sock
basedir=/usr/local/mysql5.6-install
datadir=/usr/local/mysql5.6-install/data
pid-file=/usr/local/mysql5.6-install/data/mysql.pid
user=mysql
bind-address=0.0.0.0
server-id=1
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'
symbolic-links=0
max_allowed_packet=16M
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
skip-name-resolve
skip-grant-tables
back_log=500
max_connections=3000
max_user_connections=800
wait_timeout=1814400
thread_concurrency=16
innodb_buffer_pool_size=1024M
innodb_additional_mem_pool_size=20M
innodb_log_buffer_size=20M
innodb_log_file_size=140M
innodb_lock_wait_timeout=500
query_cache_size=40M
read_buffer_size=4M
sort_buffer_size=4M
read_rnd_buffer_size=8M
tmp_table_size=16M
thread_cache_size=64
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
八、配置完成后,启动服务,阳光总在风雨后~请相信有彩虹~
#service mysql start
修改root密码:mysqladmin -u root password "我是新来的密码"
登录mysql: mysql -u root -p
幺蛾子又来鸟、我们好像更改了安装目录,因此找不到mysqladmin 和 mysql 命令了md,做个软链接
#ln -s /usr/local/mysql-install/mysqladmin /usr/bin
#ln -s /usr/local/mysql-install/bin/mysql /usr/bin
# mysqladmin -u.....
九、最后一步,新增马甲、配置权限
sql> grant usage on *.* to 'oliver'@'localhost' identified by '新密码' with grant option;
sql> grant all privileges on *.* to ‘oliver‘@‘localhost‘ identified by '密码';
sql> grant all privileges on *.* to ‘oliver‘@‘%‘ identified by '密码';
sql> flush privileges;
END,如果你也成功了,那么恭喜您!
本文详细介绍如何从MySQL 5.5升级至5.6版本的过程,包括安装环境准备、源码编译、配置文件调整及服务启动等关键步骤。
187

被折叠的 条评论
为什么被折叠?



