采用二进制包安装mysql

本文是在CentOS7系统平台下安装Mysql5.6.26版本数据库的操作说明,如有错误,请指正。

系统平台:CentOS-7-x86_64   

数据库版本:mysql-5.6.26

 

Mysql镜像文件下载地址:http://dev.mysql.com/downloads/mirrors.html

本次演示的Mysql安装包版本:mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz

1、添加mysql用户组及mysql用户

[root@localhost ~]# groupadd mysql

[root@localhost ~]# useradd -r -g mysql mysql

2、将二进制文件解压到指定的安装目录:/usr/local/mysql

到mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz包的目录下,解压到/usr/local目录下:

[root@localhost tmp]# tar zxvf mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz -C /usr/local/

到/usr/local/目录中,重命名解压出来的目录名,改为mysql:

[root@localhost tmp]# cd /usr/local/

[root@localhost local]# mv mysql-5.6.26-linux-glibc2.5-x86_64 mysql

查看此目录下文件:

[root@localhost local]# cd mysql/

[root@localhost mysql]# ls
bin     data  include         lib mysql-test  scripts  sql-bench
COPYING docs  INSTALL-BINARY  man README      share    support-files

注:/usr/local/mysql/下的目录结构

Directory

Contents of Directory

bin

Client programs and the mysqld server

data

Log files, databases

docs

Manual in Info format

man

Unix manual pages

include

Include (header) files

lib

Libraries

scripts

mysql_install_db

share

Miscellaneous support files, including error messages, sample configuration files, SQL for database installation

sql-bench

Benchmarks

 

3、创建mysql数据存放的目录:/data/mysql

[root@localhost mysql]# mkdir -p /data/mysql

4、更改所属的组和用户

[root@localhost mysql]# chown -R mysql:mysql /usr/local/mysql/

[root@localhost mysql]# chown -R mysql:mysql /data/mysql/

5、初始化mysql

注释:以mysql用户执行mysql_install_db脚本,基本目录为:/usr/local/mysql/,数据文件目录为:/data/mysql/

[root@localhost mysql]# pwd
/usr/local/mysql

[root@localhost mysql]#./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysql/

Installing MySQL system tables...2015-08-3114:24:16 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated.Please use --explicit_defaults_for_timestamp server option (see documentationfor more details).
2015-08-31 14:24:16 0 [Note]/usr/local/mysql//bin/mysqld (mysqld 5.6.26) starting as process 36847 ...
2015-08-31 14:24:17 36847 [Note] InnoDB:Using atomics to ref count buffer pool pages
2015-08-31 14:24:17 36847 [Note] InnoDB:The InnoDB memory heap is disabled
2015-08-31 14:24:17 36847 [Note] InnoDB:Mutexes and rw_locks use GCC atomic builtins
2015-08-31 14:24:17 36847 [Note] InnoDB:Memory barrier is not used
2015-08-31 14:24:17 36847 [Note] InnoDB:Compressed tables use zlib 1.2.3
2015-08-31 14:24:17 36847 [Note] InnoDB:Using Linux native AIO
2015-08-31 14:24:17 36847 [Note] InnoDB:Using CPU crc32 instructions
2015-08-31 14:24:17 36847 [Note] InnoDB:Initializing buffer pool, size = 128.0M
2015-08-31 14:24:17 36847 [Note] InnoDB:Completed initialization of buffer pool
2015-08-31 14:24:17 36847 [Note] InnoDB:The first specified data file ./ibdata1 did not exist: a new database to becreated!
2015-08-31 14:24:17 36847 [Note] InnoDB:Setting file ./ibdata1 size to 12 MB
2015-08-31 14:24:17 36847 [Note] InnoDB:Database physically writes the file full: wait...
2015-08-31 14:24:17 36847 [Note] InnoDB:Setting log file ./ib_logfile101 size to 48 MB
2015-08-31 14:24:18 36847 [Note] InnoDB:Setting log file ./ib_logfile1 size to 48 MB
2015-08-31 14:24:18 36847 [Note] InnoDB:Renaming log file ./ib_logfile101 to ./ib_logfile0
2015-08-31 14:24:18 36847 [Warning] InnoDB:New log files created, LSN=45781
2015-08-31 14:24:18 36847 [Note] InnoDB:Doublewrite buffer not found: creating new
2015-08-31 14:24:18 36847 [Note] InnoDB:Doublewrite buffer created
2015-08-31 14:24:18 36847 [Note] InnoDB:128 rollback segment(s) are active.
2015-08-31 14:24:18 36847 [Warning] InnoDB:Creating foreign key constraint system tables.
2015-08-31 14:24:18 36847 [Note] InnoDB:Foreign key constraint system tables created
2015-08-31 14:24:18 36847 [Note] InnoDB:Creating tablespace and datafile system tables.
2015-08-31 14:24:18 36847 [Note] InnoDB:Tablespace and datafile system tables created.
2015-08-31 14:24:18 36847 [Note] InnoDB:Waiting for purge to start
2015-08-31 14:24:18 36847 [Note] InnoDB:5.6.26 started; log sequence number 0
2015-08-31 14:24:19 36847 [Note] Binlog end
2015-08-31 14:24:19 36847 [Note] InnoDB:FTS optimize thread exiting.
2015-08-31 14:24:19 36847 [Note] InnoDB:Starting shutdown...
2015-08-31 14:24:20 36847 [Note] InnoDB:Shutdown completed; log sequence number 1625977
OK

Filling help tables...2015-08-31 14:24:20 0[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use--explicit_defaults_for_timestamp server option (see documentation for moredetails).
2015-08-31 14:24:20 0 [Note]/usr/local/mysql//bin/mysqld (mysqld 5.6.26) starting as process 36869 ...
2015-08-31 14:24:20 36869 [Note] InnoDB:Using atomics to ref count buffer pool pages
2015-08-31 14:24:20 36869 [Note] InnoDB:The InnoDB memory heap is disabled
2015-08-31 14:24:20 36869 [Note] InnoDB:Mutexes and rw_locks use GCC atomic builtins
2015-08-31 14:24:20 36869 [Note] InnoDB:Memory barrier is not used
2015-08-31 14:24:20 36869 [Note] InnoDB:Compressed tables use zlib 1.2.3
2015-08-31 14:24:20 36869 [Note] InnoDB:Using Linux native AIO
2015-08-31 14:24:20 36869 [Note] InnoDB:Using CPU crc32 instructions
2015-08-31 14:24:20 36869 [Note] InnoDB:Initializing buffer pool, size = 128.0M
2015-08-31 14:24:20 36869 [Note] InnoDB:Completed initialization of buffer pool
2015-08-31 14:24:20 36869 [Note] InnoDB:Highest supported file format is Barracuda.
2015-08-31 14:24:21 36869 [Note] InnoDB:128 rollback segment(s) are active.
2015-08-31 14:24:21 36869 [Note] InnoDB:Waiting for purge to start
2015-08-31 14:24:21 36869 [Note] InnoDB:5.6.26 started; log sequence number 1625977
2015-08-31 14:24:21 36869 [Note] Binlog end
2015-08-31 14:24:21 36869 [Note] InnoDB:FTS optimize thread exiting.
2015-08-31 14:24:21 36869 [Note] InnoDB:Starting shutdown...
2015-08-31 14:24:22 36869 [Note] InnoDB:Shutdown completed; log sequence number 1625987
OK

To start mysqld at boot time you have tocopy
support-files/mysql.server to the rightplace for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THEMySQL root USER !

To do so, start the server, then issue thefollowing commands:

 /usr/local/mysql//bin/mysqladmin -u root password 'new-password'

 /usr/local/mysql//bin/mysqladmin -u root -h localhost.localdomainpassword 'new-password'

Alternatively you can run:

 /usr/local/mysql//bin/mysql_secure_installation

which will also give you the option ofremoving the test

databases and anonymous user created bydefault.  This is

strongly recommended for productionservers.

See the manual for more instructions.

You can start the MySQL daemon with:

  cd. ; /usr/local/mysql//bin/mysqld_safe &

You can test the MySQL daemon withmysql-test-run.pl

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

Please report any problems athttp://bugs.mysql.com/

The latest information about MySQL isavailable on the web at

 http://www.mysql.com

Support MySQL by buying support/licenses athttp://shop.mysql.com

New default config file was created as/usr/local/mysql//my.cnf and
will be used by default by the server whenyou start it.
You may edit this file to change serversettings

WARNING: Default config file /etc/my.cnfexists on the system
This file will be read by default by theMySQL server
If you do not want to use this, eitherremove it, or use the
--defaults-file argument to mysqld_safewhen starting the server

注:本次启动有一个报错如下:

FATAL ERROR: please install the followingPerl modules before executing ./scripts/mysql_install_db:

Data::Dumper

解决方案:

[root@localhost mysql]# yum install -yperl-Module-Install.noarch

 

6、修改my.cnf配置文件

复制/usr/local/mysql/support-files/my-default.conf 文件到/etc/ 目录下,覆盖原有的配置文件mysql/my.cnf:

[root@localhost mysql]# cp support-files/my-default.cnf  /etc/my.cnf

 

修改/etc/my.cnf 文件,指定datadir、basedir 路径,同时开启3306端口:

basedir = /usr/local/mysql
datadir = /data/mysql
port = 3306

7、复制mysql 启动脚本mysql.server 到/etc/init.d/mysqld

[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld

8、修改启动脚本的权限为755,赋予执行权限

[root@localhost mysql]# chmod 755 /etc/init.d/mysqld

9、通过chkconfig命令将mysqld服务加入到自启动服务项中:

[root@localhost init.d]# pwd
/etc/init.d

[root@localhost init.d]# chkconfig --add mysqld

检查是否加入到自动启动

[root@localhost init.d]# chkconfig --list mysqld
mysqld          0:off   1:off  2:on    3:on    4:on   5:on    6:off

10、启动mysql服务:

[root@localhost mysql]# service mysqld start
Starting MySQL... SUCCESS!

11、进入mysql

[root@localhost mysql]#/usr/local/mysql/bin/mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.26 MySQL CommunityServer (GPL)

Copyright (c) 2000, 2015, Oracle and/or itsaffiliates. All rights reserved.

Oracle is a registered trademark of OracleCorporation and/or its
affiliates. Other names may be trademarksof their respective
owners.

Type 'help;' or '\h' for help. Type '\c' toclear the current input statement.

mysql>

注:在/etc/profile中加入以下环境变量,可以用mysql代替/usr/local/mysql/bin/mysql启动

MYSQL_HOME=/usr/local/mysql

exportPATH=$PATH:$MYSQL_HOME/bin


设置后需要重新加载一下:

[root@localhost mysql]# source /etc/profile

再次进入mysql

[root@localhost mysql]# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.26 MySQL Community Server (GPL)

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

原创文章,作者:cnc,如若转载,请注明出处:http://www.178linux.com/74775

(1)
cnccnc
上一篇 2017-05-04
下一篇 2017-05-04

相关推荐

  • 文件系统自动挂载

    什么是文件系统自动挂载?          利用mount在shell终端进行挂载的时,开机自动启动文件文件系统不会自动挂载,我们需要开机的时候自动挂载文件系统,称为文件系统自动挂载 实现Linux自动挂载文件:/etc/fstab Linux中挂载注意事项:  &nb…

    Linux干货 2016-08-29
  • 小练习题。【第四周】

    1、复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其他用户均没有任何访问权限。 home]# chmod g-rwx,o-rwx -R tuser1 2、编辑/etc/group文件,添加组hadoop。 /]# vim /etc/group …

    Linux干货 2016-11-26
  • 第一周

    1、描述计算机的组成与功能 计算器是由运算器,控制器,存储器,输入设备和输出设备五大部件组成;每一部件分别按要求执行特定的功能,具体功能如下: (1)运算器:完成各种算术运算和逻辑运算的装置,能进行加、减、乘、除等数学运算,也能作比较、判断、查找、逻辑运算等。 (2)控制器:控制器是计算机机指挥和控制其它各部分工作的中心,其工作过程和人的大脑指挥和控制人的各…

    Linux干货 2017-01-02
  • sed,vim练习

    1 、删除/etc/grub2.cfg 文件中所有以空白开头的行行首的 空白字符 [root@localhost ~]# sed -r 's@^[[:space:]]+@@' /etc/grub2.cfg 2 、删除/etc/fstab 文件中所有以#开头,后面至少跟一个空白字符的行的行首…

    Linux干货 2016-08-10
  • 上海2016全球运维大会 美女辣妹吸引眼球!

    国内第一个运维行业大会 GOPS 2016全球运维大会(上海站)在2016年9月23-24日在上海雅悦新天地大酒店举办,面向IT及传统行业、广大运维技术人员,传播先进技术思想和理念,分享业内最佳实践。 参会两日,虽然大会主角是运维技术交流学习,不过却意料之外的邂逅了另一道靓丽的风景,瞬间燃了… 在会场,站立着一群高挑美女,我的…

    2016-12-05
  • 基于Redis的开源分布式服务Codis

    Redis在豌豆荚的使用历程——单实例==》多实例,业务代码中做sharding==》单个Twemproxy==》多个Twemproxy==》Codis,豌豆荚自己开发的分布式Redis服务。在大规模的Redis使用过程中,他们发现Redis受限于多个方面:单机内存有限、带宽压力、单点问题、不能动态扩容以及磁盘损坏时的数据抢救。 Redis通常有3个使用途径…

    Linux干货 2015-02-25