1.源码包安装,进入mysql.com网站,注册一个oracle账号,选择5.6community Editon ,选择source code ,下载类似:
mysql-xxx(version).tar.gz安装包,大约30M。
2.上传到Linux上,解压命令 tar -xvzf mysql-5.6.32.tar.gz
3.进入到解压后文件夹mysql-5.6.32,运行命令如下
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_PARTITION_STORAGE_ENGINE=1
第一次运行很有可能会报错。在最后,cmake会提示你少了哪些安装必须的包,比如我的系统提示我缺少了 ncurses-devel,执行
如下命令安装 yum install ncurses-devel。删除CMakeCache.txt文件,重新执行cmake.
4.cmake 进行安装前的验证检查,检查最后通过会输出如下信息:
BLE_DOWNLOADS=1 to automatically download and build required components from source.
-- If you are inside a firewall, you may need to use an http proxy: export http_proxy=http://example.com:80
Warning: Bison executable not found in PATH
-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl
-- CMAKE_BUILD_TYPE: RelWithDebInfo
-- COMPILE_DEFINITIONS: HAVE_CONFIG_H
-- CMAKE_C_FLAGS: -Wall -Wextra -Wformat-security -Wvla -Wwrite-strings -Wdeclaration-after-statement
-- CMAKE_CXX_FLAGS: -Wall -Wextra -Wformat-security -Wvla -Woverloaded-virtual -Wno-unused-parameter
-- CMAKE_C_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mysql/mysql-5.6.32
5.安装前cmake 成功执行后,运行make 命令,执行编译,大概需要10分钟。最后输出如下信息,表示built完成
[100%] Built target mysql_embedded
Scanning dependencies of target mysqltest_embedded
[100%] Building CXX object libmysqld/examples/CMakeFiles/mysqltest_embedded.dir/__/__/client/mysqltest.cc.o
Linking CXX executable mysqltest_embedded
[100%] Built target mysqltest_embedded
Scanning dependencies of target my_safe_process
[100%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o
Linking CXX executable my_safe_process
[100%] Built target my_safe_process
6.接着执行命令:make install
-- Installing: /usr/local/mysql/sql-bench/innotest1a
-- Installing: /usr/local/mysql/sql-bench/innotest2
-- Installing: /usr/local/mysql/sql-bench/test-create
-- Installing: /usr/local/mysql/sql-bench/crash-me
-- Installing: /usr/local/mysql/sql-bench/innotest1
-- Installing: /usr/local/mysql/sql-bench/bench-init.pl
-- Installing: /usr/local/mysql/sql-bench/test-wisconsin
-- Installing: /usr/local/mysql/sql-bench/compare-results
-- Installing: /usr/local/mysql/sql-bench/copy-db
7.进入到指定的安装目录下/usr/local/mysql
[root@mysqlIns mysql-5.6.32]# cd /usr/local/mysql
[root@mysqlIns mysql]# ls
bin data include man README share support-files
COPYING docs lib mysql-test scripts sql-bench
8.进入data,你会发现只有test库,没有mysql库,performance_schema库。安装mysql库,初始化Innodb,执行命令:
./scripts/mysql_install_db --user=mysql
有错误报错如下:
2016-08-26 11:42:00 22040 [ERROR] InnoDB: space header page consists of zero bytes in data file ./ibdata1
2016-08-26 11:42:00 22040 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!
2016-08-26 11:42:00 22040 [ERROR] Plugin 'InnoDB' init function returned error.
2016-08-26 11:42:00 22040 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2016-08-26 11:42:00 22040 [ERROR] Unknown/unsupported storage engine: InnoDB
2016-08-26 11:42:00 22040 [ERROR] Aborting
解决办法:把innodb在datadir目录下的innodb系统文件ibdata1,重做日志文件ib_logfile0-4,二进制日志binlog*删除掉。
重新执行 ./scripts/mysql_install_db --user=mysql 问题解决。
9.最后启动mysql,大功告成,启动mysql
mysqld_safe --defaults-file=/usr/local/mysql/my.cnf
10.更改root密码,按照提示
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h mysqlIns password 'new-password'
11.最后贴出我的my.cnf 文件:
[mysqld]
innodb_data_file_path=ibdata1:12M:autoextend
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-bin=/usr/local/mysql/data/binlog
server_id=3
innodb_log_buffer_size=8388608
innodb_log_compressed_pages=ON
innodb_log_file_size=50331648
innodb_log_files_in_group=5
innodb_log_group_home_dir=./
innodb_data_file_path=ibdata1:12M:autoextend
slow_query_log=on
long_query_time=5
slow_query_log_file=/usr/local/mysql/data/mysqlIns-slow.log
sql_mode=oracle
character_set_server=utf8
collation_server=utf8_general_ci
[mysqld_safe]
log-error=/usr/local/mysql/data/mysqld.log
pid-file=/usr/local/mysql/data/mysqld.pid
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30393770/viewspace-2124065/
,如需转载,请注明出处,否则将追究法律责任。