您的位置:首页 > 运维架构 > Linux

Centos6.5 minimal版编辑安装Mysql5.6.34

2016-11-08 17:46 330 查看

Centos6.5 minimal版编辑安装Mysql5.6.34
以下部分内容借鉴Michael_DD的blog内容
http://blog.itpub.net/29500582/viewspace-1377052/

Mysql5.6.34源代码安装

1 环境介绍
操作系统:Centos6.5 X64

2 安装软件
采用源码安装方式
1. mysql安装包:mysql-5.6.34.tar.gz
Mysql 下载地址:http://dev.mysql.com/downloads/
2. Cmake安装包
mysql5.5以后是通过cmake来编译的
wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
wget http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gz(本Blog测试用的版本) cmake-2.8.4.tar.gz

3 删除Linux自带的Mysql
如果已经安装了Mysql其他版本,先删除
3.1 检查是否安装了MySQL
[root@test /]# rpm -qa | grep -i mysql
mysql-libs-5.1.52-1.el6_0.1.i686
qt-mysql-4.6.2-20.el6.i686
mysql-server-5.1.52-1.el6_0.1.i686
mysql-5.1.52-1.el6_0.1.i686
perl-DBD-MySQL-4.013-3.el6.i686
3.2 使用yum来删除MySQL(本人建议rpm -e --nodeps卸载)
[root@test ~]# yum -y remove mysql-libs-5.1.52-1.el6_0.1.i686
逐个删除吧!

4 服务器上安装Mysql

4.1 先安装cmake
[root@test ]# tar -zxvf cmake-2.8.4.tar.gz
[root@test ]# cd cmake-2.8.4(相应版本对应目录)
[root@test ]# ./configure
[root@test ]# make或 gmake
[root@test ]# make install 或gmake install

4.2 创建mysql的安装目录及数据存放目录
[root@test cmake-2.8.4]# mkdir /mysql //安装mysql
[root@test cmake-2.8.4]# mkdir /mysql/data //存放数据

4.3 创建mysql用户及用户组
[root@test cmake-2.8.4]# groupadd mysql
[root@test cmake-2.8.4]# useradd mysql -g mysql
赋予数据存放目录权限:
chown mysql:mysql -R /mysql
4.4 编译安装mysql
编译
[root@test tmp]# tar -zxvf mysql-5.6.34.tar.gz
[root@test tmp]# cd mysql-5.6.34
[root@test mysql-5.6.22]#cmake . -DCMAKE_INSTALL_PREFIX=/mysql -DMYSQL_DATADIR=/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1

参数说明:
CMAKE_INSTALL_PREFIX : MySQL安装目录
SYSCONFDIR : 配置文件目录
MYSQL_DATADIR :数据库目录
MYSQL_TCP_PORT :数据库端口
MYSQL_UNIX_ADDR :安排个目录放mysql.sock文件把,可以设置为日志存放,data存放目录等位置
WITH_EXTRA_CHARSETS : 字符
WITH_SSL :the type of SSL
WITH_EMBEDDED_SERVER :Whether to build embedded server (默认:OFF)
ENABLED_LOCAL_INFILE :Whether to enable LOCAL for LOAD DATA INFILE(默认:OFF) 允许从本地导入数据
WITH_INNOBASE_STORAGE_ENGINE: 1

参数详细见:http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html

如果发生错误查看:
。。。/mysql-5.6.15/CMakeFiles下的CMakeError.log、CMakeOutput.log文件
注意事项:
重新编译时,需要清除旧的对象文件和缓存信息。
# rm -f CMakeCache.txt

错误:Curses library not found. Please install appropriate package
解决办法:
make clean
rm -rf /etc/my.cnf
rm -f CMakeCache.txt
yum -y install ncurses-devel

安装
[root@test mysql-5.6.15]# make
[root@test mysql-5.6.15]# make install

4.5 初始化数据库
[root@test mysql]# cd /mysql
[root@test mysql]# mkdir etc
[root@test mysql]# mkdir log
[root@test mysql]# chown -R mysql:mysql .
[root@test scripts]# cd /mysql/scripts
[root@test scripts]# ./mysql_install_db --user=mysql --basedir=/mysql/ --datadir=/mysql/data/
Installing MySQL system tables...2014-12-23 11:26:21 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-12-23 11:26:21 24207 [Note] InnoDB: Using atomics to ref count buffer pool pages
2014-12-23 11:26:21 24207 [Note] InnoDB: The InnoDB memory heap is disabled
2014-12-23 11:26:21 24207 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-12-23 11:26:21 24207 [Note] InnoDB: Memory barrier is not used
2014-12-23 11:26:21 24207 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-12-23 11:26:21 24207 [Note] InnoDB: Using Linux native AIO
2014-12-23 11:26:21 24207 [Note] InnoDB: Using CPU crc32 instructions
2014-12-23 11:26:21 24207 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-12-23 11:26:21 24207 [Note] InnoDB: Completed initialization of buffer pool
2014-12-23 11:26:21 24207 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2014-12-23 11:26:21 24207 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2014-12-23 11:26:21 24207 [Note] InnoDB: Database physically writes the file full: wait...
2014-12-23 11:26:21 24207 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2014-12-23 11:26:21 24207 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2014-12-23 11:26:22 24207 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2014-12-23 11:26:22 24207 [Warning] InnoDB: New log files created, LSN=45781
2014-12-23 11:26:22 24207 [Note] InnoDB: Doublewrite buffer not found: creating new
2014-12-23 11:26:22 24207 [Note] InnoDB: Doublewrite buffer created
2014-12-23 11:26:22 24207 [Note] InnoDB: 128 rollback segment(s) are active.
2014-12-23 11:26:22 24207 [Warning] InnoDB: Creating foreign key constraint system tables.
2014-12-23 11:26:22 24207 [Note] InnoDB: Foreign key constraint system tables created
2014-12-23 11:26:22 24207 [Note] InnoDB: Creating tablespace and datafile system tables.
2014-12-23 11:26:22 24207 [Note] InnoDB: Tablespace and datafile system tables created.
2014-12-23 11:26:22 24207 [Note] InnoDB: Waiting for purge to start
2014-12-23 11:26:22 24207 [Note] InnoDB: 5.6.22 started; log sequence number 0
2014-12-23 11:26:25 24207 [Note] Binlog end
2014-12-23 11:26:25 24207 [Note] InnoDB: FTS optimize thread exiting.
2014-12-23 11:26:25 24207 [Note] InnoDB: Starting shutdown...
2014-12-23 11:26:26 24207 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK

Filling help tables...2014-12-23 11:26:26 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-12-23 11:26:26 24229 [Note] InnoDB: Using atomics to ref count buffer pool pages
2014-12-23 11:26:26 24229 [Note] InnoDB: The InnoDB memory heap is disabled
2014-12-23 11:26:26 24229 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-12-23 11:26:26 24229 [Note] InnoDB: Memory barrier is not used
2014-12-23 11:26:26 24229 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-12-23 11:26:26 24229 [Note] InnoDB: Using Linux native AIO
2014-12-23 11:26:26 24229 [Note] InnoDB: Using CPU crc32 instructions
2014-12-23 11:26:26 24229 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-12-23 11:26:26 24229 [Note] InnoDB: Completed initialization of buffer pool
2014-12-23 11:26:26 24229 [Note] InnoDB: Highest supported file format is Barracuda.
2014-12-23 11:26:26 24229 [Note] InnoDB: 128 rollback segment(s) are active.
2014-12-23 11:26:26 24229 [Note] InnoDB: Waiting for purge to start
2014-12-23 11:26:26 24229 [Note] InnoDB: 5.6.22 started; log sequence number 1625977
2014-12-23 11:26:27 24229 [Note] Binlog end
2014-12-23 11:26:27 24229 [Note] InnoDB: FTS optimize thread exiting.
2014-12-23 11:26:27 24229 [Note] InnoDB: Starting shutdown...
2014-12-23 11:26:28 24229 [Note] InnoDB: Shutdown completed; log sequence number 1625987
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:

/mysql//bin/mysqladmin -u root password 'new-password'
/mysql//bin/mysqladmin -u root -h test password 'new-password'

Alternatively you can run:

/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 . ; /mysql//bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

cd mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
New default config file was created as /mysql//my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

[root@test scripts]#

#
#
#

[root@test scripts]# cd /mysql
[root@test mysql]# chown -R root .
[root@test mysql]# chown -R mysql data
[root@test mysql]# bin/mysqld_safe --user=mysql &
[root@testdb1 mysql]# bin/mysqld_safe --user=mysql &
[1] 24329
[root@testdb1 mysql]# 141223 11:30:32 mysqld_safe Logging to '/mysql/data/test.err'.
141223 11:30:32 mysqld_safe Starting mysqld daemon with databases from /mysql/data

4.6 配置数据库
修改密码:
[root@test mysql]# bin/mysqladmin -u root password 'mysql'
Warning: Using a password on the command line interface can be insecure.
[root@test mysql]# ps -ef | grep mysql
root 24329 23025 0 11:30 pts/0 00:00:00 /bin/sh bin/mysqld_safe --user=mysql
mysql 24426 24329 0 11:30 pts/0 00:00:00 /mysql/bin/mysqld --basedir=/mysql --datadir=/mysql/data --plugin-dir=/mysql/lib/plugin --user=mysql --log-error=/mysql/data/testdb1.err --pid-file=/mysql/data/testdb1.pid
root 24496 23025 0 11:32 pts/0 00:00:00 grep mysql
[root@test mysql]# bin/mysql -u root -pmysql
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.22 Source distribution

Copyright (c) 2000, 2014, 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>

[root@test mysql]# cp support-files/mysql.server /etc/init.d/
[root@test mysql]# cp support-files/my-default.cnf etc/my.cnf

编辑etc/my.cnf,zai [mysqld]下增加lower_case_table_names=1
设置环境:
[root@test mysql]# cd /etc
[root@test etc]# vi profile
在文件最后增加:
PATH=/opt/mysql/bin:/opt/mysql/lib:$PATH
export PATH

生效环境变量:
[root@test etc]# source profile

4.7 手工启动数据库
[root@test etc]# service mysql.server status
SUCCESS! MySQL running (24426)
[root@test etc]# service mysql.server stop
Shutting down MySQL..141223 11:37:29 mysqld_safe mysqld from pid file /mysql/data/testdb1.pid ended
SUCCESS!
[1]+ Done bin/mysqld_safe --user=mysql (wd: /mysql)
(wd now: /etc)
[root@test etc]# service mysql.server start
Starting MySQL. SUCCESS!
[root@test etc]#

4.8 设置自动启动
[root@test mysql]# chkconfig --level 35 mysql.server on
[root@test mysql]# chkconfig | grep mysql
mysql.server 0:off 1:off 2:on 3:on 4:on 5:on 6:off
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mysql编辑安装