1、安装准备
先从mysql官方网站下载安装包,大家也可以从我的网盘中下载,点击下载mysql-5.6.17.tar.gz。安装前请保障gcc库已安装。
查看mysql官方关于5.6的源代码安装文档,发现官方使用cmake命令进行编译的,mysql 5.5之后的版本编译安装需要使用cmake,可以从官网下载:http://www.cmake.org/files/v2.8/cmake-2.8.12.1.tar.gz
2、安装
第一步:解压mysql源码包,进入源码目录,配置mysql编译参数
[root@zhhuang-pc 下载]# tar -zxvf mysql-5.6.17-linux-glibc2.5-x86_64.tar.gz
第二步:编译源码
从下面的文件列表中中可以看出解压后的mysql5.6.17源码中没有./configure文件,mysql 5.5之后需要使用cmake进行编译安装mysql
[root@zhhuang-pc mysql-5.6.17-linux-glibc2.5-x86_64]# ls -l 总用量 156 drwxr-xr-x. 2 root root 4096 4月 5 01:29 bin -rw-r--r--. 1 7161 wheel 17987 3月 15 03:07 COPYING drwxr-xr-x. 3 root root 4096 4月 5 01:29 data drwxr-xr-x. 2 root root 4096 4月 5 01:29 docs drwxr-xr-x. 3 root root 4096 4月 5 01:29 include -rw-r--r--. 1 7161 wheel 89144 3月 15 03:07 INSTALL-BINARY drwxr-xr-x. 3 root root 4096 4月 5 01:29 lib drwxr-xr-x. 4 root root 4096 4月 5 01:29 man drwxr-xr-x. 10 root root 4096 4月 5 01:29 mysql-test -rw-r--r--. 1 7161 wheel 2496 3月 15 03:07 README drwxr-xr-x. 2 root root 4096 4月 5 01:29 scripts drwxr-xr-x. 28 root root 4096 4月 5 01:29 share drwxr-xr-x. 4 root root 4096 4月 5 01:29 sql-bench drwxr-xr-x. 3 root root 4096 4月 5 01:29 support-files第三步:解压编译cmake
[root@zhhuang-pc 下载]# tar -zxvf cmake-2.8.12.1.tar.gz [root@zhhuang-pc cmake-2.8.12.1]# cd cmake-2.8.12.1 [root@zhhuang-pc cmake-2.8.12.1]# ./configure [root@zhhuang-pc cmake-2.8.12.1]# make && make install第四步:检查cmake是否已经安装完成
[root@zhhuang-pc cmake-2.8.12.1]# cmake --version cmake version 2.8.12.1 [root@zhhuang-pc cmake-2.8.12.1]#第四步:编译安装mysql
使用cmak -help查看cmake命令的使用及cmake参数的说明
[root@zhhuang-pc cmake-2.8.12.1]# cmake -help安装前讲数据库安装位置(/usr/local/mysql)、数据库存储位置(/usr/local/mysql/data)、mysql.sock文件存储文件夹(
/
var
/lib/mysql/
)创建好但是使用cmake编译mysql,编译参数自定义,安装提示错误(does not appear to contain CMakeLists.txt):
[root@zhhuang-pc mysql-5.6.17-linux-glibc2.5-x86_64]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql > -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock > -DDEFAULT_CHARSET=utf8 > -DDEFAULT_COLLATION=utf8_general_ci > -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk > -DWITH_MYISAM_STORAGE_ENGINE=1 > -DWITH_INNOBASE_STORAGE_ENGINE=1 > -DWITH_MEMORY_STORAGE_ENGINE=1 > -DWITH_READLINE=1 > -DENABLED_LOCAL_INFILE=1 > -DMYSQL_DATADIR=/usr/local/mysql/data > -DMYSQL_USER=mysql CMake Error: The source directory "/home/zhhuang/下载/mysql-5.6.17-linux-glibc2.5-x86_64" does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI.使用camke命令默认编译报错如下:
[root@zhhuang-pc mysql-5.6.17-linux-glibc2.5-x86_64]# cmake . CMake Error: The source directory "/home/zhhuang/下载/mysql-5.6.17-linux-glibc2.5-x86_64" does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI. [root@zhhuang-pc mysql-5.6.17-linux-glibc2.5-x86_64]#查看mysql-5.6.17-linux-glibc2.5-x86_64文件夹,发现没有CMakeLists.txt文件。
我重新从官方网站下载了一个包,如下图所示选择下载
[root@zhhuang-pc 下载]# tar -zxvf mysql-5.6.17.tar.gz [root@zhhuang-pc 下载]# cd mysql-5.6.17 [root@zhhuang-pc mysql-5.6.17]# ls -l 总用量 692 drwxr-xr-x. 2 7161 wheel 4096 3月 15 03:07 BUILD -rw-r--r--. 1 7161 wheel 142 3月 15 03:07 BUILD-CMAKE drwxr-xr-x. 2 7161 wheel 4096 3月 15 03:07 client drwxr-xr-x. 4 7161 wheel 4096 3月 15 03:07 cmake -rw-r--r--. 1 7161 wheel 19984 3月 15 03:07 CMakeLists.txt drwxr-xr-x. 3 7161 wheel 4096 3月 15 03:07 cmd-line-utils -rw-r--r--. 1 7161 wheel 19671 3月 15 03:07 config.h.cmake -rw-r--r--. 1 7161 wheel 36960 3月 15 03:07 configure.cmake -rw-r--r--. 1 7161 wheel 17987 3月 15 03:07 COPYING drwxr-xr-x. 2 7161 wheel 4096 3月 15 03:07 dbug drwxr-xr-x. 2 7161 wheel 4096 3月 15 03:07 Docs -rw-r--r--. 1 7161 wheel 65958 3月 15 03:07 Doxyfile-perfschema drwxr-xr-x. 3 7161 wheel 4096 3月 15 03:07 extra drwxr-xr-x. 4 7161 wheel 4096 3月 15 03:07 include -rw-r--r--. 1 7161 wheel 374213 3月 15 03:07 INSTALL-SOURCE -rw-r--r--. 1 7161 wheel 247 3月 15 03:07 INSTALL-WIN-SOURCE drwxr-xr-x. 7 7161 wheel 4096 3月 15 03:07 libevent drwxr-xr-x. 3 7161 wheel 4096 3月 15 03:07 libmysql drwxr-xr-x. 3 7161 wheel 4096 3月 15 03:07 libmysqld drwxr-xr-x. 2 7161 wheel 4096 3月 15 03:07 libservices drwxr-xr-x. 2 7161 wheel 4096 3月 15 03:07 man drwxr-xr-x. 10 7161 wheel 4096 3月 15 03:07 mysql-test drwxr-xr-x. 2 7161 wheel 4096 3月 15 03:07 mysys drwxr-xr-x. 2 7161 wheel 4096 3月 15 03:07 mysys_ssl drwxr-xr-x. 7 7161 wheel 4096 3月 15 03:07 packaging drwxr-xr-x. 9 7161 wheel 4096 3月 15 03:07 plugin -rw-r--r--. 1 7161 wheel 2496 3月 15 03:07 README drwxr-xr-x. 2 7161 wheel 4096 3月 15 03:07 regex drwxr-xr-x. 2 7161 wheel 4096 3月 15 03:07 scripts drwxr-xr-x. 4 7161 wheel 20480 3月 15 03:07 sql drwxr-xr-x. 5 7161 wheel 4096 3月 15 03:07 sql-bench drwxr-xr-x. 2 7161 wheel 4096 3月 15 03:07 sql-common drwxr-xr-x. 13 7161 wheel 4096 3月 15 03:07 storage drwxr-xr-x. 2 7161 wheel 4096 3月 15 03:07 strings drwxr-xr-x. 5 7161 wheel 4096 3月 15 03:07 support-files drwxr-xr-x. 2 7161 wheel 4096 3月 15 03:07 tests drwxr-xr-x. 5 7161 wheel 4096 3月 15 03:07 unittest -rw-r--r--. 1 7161 wheel 88 3月 15 03:07 VERSION drwxr-xr-x. 3 7161 wheel 4096 3月 15 03:07 vio drwxr-xr-x. 2 7161 wheel 4096 3月 15 03:07 win drwxr-xr-x. 2 7161 wheel 4096 3月 15 03:07 zlib [root@zhhuang-pc mysql-5.6.17]# cmake . [root@zhhuang-pc mysql-5.6.17]# make && make install如上所示,新下载的mysql包中含有cmake编译所需要的配置文件。
3、安装完成
第一步:测试是否安装成功
[root@zhhuang-pc mysql-5.6.17]# mysql --version mysql Ver 14.14 Distrib 5.1.71, for redhat-linux-gnu (x86_64) using readline 5.1 [root@zhhuang-pc mysql-5.6.17]#第二步:启动mysql
[root@zhhuang-pc mysql-5.6.17]# service mysqld status mysqld 已停 [root@zhhuang-pc mysql-5.6.17]# service mysqld start 初始化 MySQL 数据库: WARNING: The host ‘zhhuang-pc‘ 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... OK Filling help tables... 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: /usr/bin/mysqladmin -u root password ‘new-password‘ /usr/bin/mysqladmin -u root -h zhhuang-pc password ‘new-password‘ Alternatively you can run: /usr/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 /usr ; /usr/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd /usr/mysql-test ; perl mysql-test-run.pl Please report any problems with the /usr/bin/mysqlbug script! [确定] 正在启动 mysqld: [确定] [root@zhhuang-pc mysql-5.6.17]#第三步:修改mysql的root用户密码,登录mysqll
先使用service mysqld stop 停止服务, 使用mysql安全模式登录启动服务,修改root用户数据库登录密码
[root@zhhuang-pc mysql-5.6.17]# mysqld_safe --skip-grant-tables 140405 02:54:54 mysqld_safe Logging to ‘/var/log/mysqld.log‘. 140405 02:54:54 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql然后重新开一个SSH CH然后重新开一个SSH窗口,登录mysql数据库
[root@zhhuang-pc zhhuang]# mysql -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.1.71 Source distribution Copyright (c) 2000, 2013, 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> mysql> update user set Password=password(‘root‘) where user=‘root‘; Query OK, 3 rows affected (0.00 sec) Rows matched: 3 Changed: 3 Warnings: 0 mysql>密码成功修改为root,然后将mysqld_safe服务关闭,启动mysqld服务,使用新密码就可以登录数据库了。
第四步:关闭mysql
[root@zhhuang-pc mysql-5.6.17]# service mysqld stop 停止 mysqld: [确定] [root@zhhuang-pc mysql-5.6.17]#
本文出自 “兴趣的力度超过爱” 博客,请务必保留此出处http://xiaohuazi.blog.51cto.com/8034597/1390862