MySQL5.6 数据库安装

环境介绍
OS:Red Hat Enterprise Linux 6.4 64_X86
DATABASE:MySQL5.6
实施安装
1. 检查是否已安装mysql

(一)检查是否安装过其他版的mysql
[root@vast ~]# rpm -qa | grep -i mysql
mysql-libs-5.1.66-2.el6_3.x86_64
mysql-5.1.66-2.el6_3.x86_64
mysql-server-5.1.66-2.el6_3.x86_64
qt-mysql-4.6.2-25.el6.x86_64
perl-DBD-MySQL-4.013-3.el6.x86_64
mysql-devel-5.1.66-2.el6_3.x86_64 
(二)移除mysql软件
[root@vast ~]# yum remove mysql-5.1.66-2.el6_3.x86_64
Loaded plugins: product-id, refresh-packagekit,
 security, subscription-manager
This system is not registered to Red Hat Subscription Management.
 You can use subscription-manager to register.
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package mysql.x86_64 0:5.1.66-2.el6_3 will be erased
--> Processing Dependency: mysql = 
5.1.66-2.el6_3 for package: mysql-devel-5.1.66-2.el6_3.x86_64
--> Processing Dependency: mysql = 
5.1.66-2.el6_3 for package: mysql-server-5.1.66-2.el6_3.x86_64
    ……
    ……
Remove       11 Package(s)

Installed size: 74 M
Is this ok [y/N]: y  输入y确认删除
……
Complete!
(三)再次检查,如果存在继续删除
[root@vast ~]# rpm -qa | grep -i mysql
mysql-libs-5.1.66-2.el6_3.x86_64
qt-mysql-4.6.2-25.el6.x86_64
perl-DBD-MySQL-4.013-3.el6.x86_64
下一条的删除内容就省略了,期间输入y确认删除,同上一步。
[root@vast ~]# yum remove mysql-libs-5.1.662.el6_3.x86_64
(四)再次检查
[root@vast ~]# rpm -qa | grep -i mysql
[root@vast ~]#

2. 创建用户组以及用户

[root@vast ~]# groupadd mysql
[root@vast ~]# useradd -r -g mysql -s /bin/false mysql
建立一个mysql组
建立一个名为mysql的用户,归为mysql组下,没有定义其家目录(安全考虑)

3. 上传安装包
4. 解压安装包

到压缩包存放的路径下
开始解压缩文件 
z 解压 .gz结尾的压缩文件
x 解压
v 可视化
f file
[root@vast tmp]# tar -zxvf mysql-5.6.31-linux-glibc2.5-x86_64.tar.gz
mysql-5.6.31-linux-glibc2.5-x86_64/bin/mysql_convert_table_format
mysql-5.6.31-linux-glibc2.5-x86_64/bin/mysqlhotcopy
mysql-5.6.31-linux-glibc2.5-x86_64/bin/mysqladmin
……
mysql-5.6.31-linux-glibc2.5-x86_64/include/mysql_com.h
mysql-5.6.31-linux-glibc2.5-x86_64/COPYING

5. 移动安装包

移动软件包到/usr/local下并改名为mysql
[root@vast tmp]# mv mysql-5.6.31-linux-glibc2.5-x86_64  /usr/local/mysql
[root@vast tmp]# cd /usr/local/
[root@vast local]# ls
bin  etc  games  include  lib  lib64  libexec  mysql  sbin  share  src

6. 创建目录并赋权

(一)更目录所属
因为mysql目录的所属权还是属于root,现更改这个权限给mysql用户及mysql组
-R表示级联赋权,将目录下的所有目录及文件都更改权限
[root@vast local]# chown mysql:mysql mysql/ -R
(二)创建一个mysql数据存放的目录
-p表示级联创建,意思就是创建完/data后在/data下创建mydb
[root@vast local]# mkdir -p /data/mydb
同样更改所属
[root@vast local]# chown mysql:mysql /data –R

7. 执行安装

[root@vast local]# cd /usr/local/mysql/scripts
这一步是连在一起打的没有换行,这里是因为本行放不下故切换一下行。
指定了uesr是mysql
dasedir是软件所在路径
datadir是数据文件存放路径
[root@vast scripts]# ./mysql_install_db  --user=mysql
 --basedir=/usr/local/mysql  --datadir=/data/mydb

WARNING: The host 'vast.vdedu' could not be looked up 
with /usr/local/mysql/bin/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...2016-09-25 11:20:25 0 
[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. 
Please use --explicit_defaults_for_timestamp server option 
(see documentation for more details).
2016-09-25 11:20:25 0 [Note] /usr/local/mysql/bin/mysqld 
(mysqld 5.6.31) starting as process 2335 ...
2016-09-25 11:20:25 2335 [Note] InnoDB: Using atomics to ref count 
buffer pool pages
2016-09-25 11:20:25 2335 [Note] InnoDB: The InnoDB memory heap is disabled
2016-09-25 11:20:25 2335 [Note] InnoDB: Mutexes and rw_locks use 
GCC atomic builtins
2016-09-25 11:20:25 2335 [Note] InnoDB: Memory barrier is not used
2016-09-25 11:20:26 2335 [Note] InnoDB: Starting shutdown...
2016-09-25 11:20:28 2335 [Note] InnoDB: Shutdown     completed; log sequence number 1625977
OK
Filling help tables...2016-09-25 11:20:28 0 
[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. 
Please use --explicit_defaults_for_timestamp server option 
(see documentation for more details).
2016-09-25 11:20:28 0 
[Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.31) starting as process 2357 ...
2016-09-25 11:20:28 2357 
[Note] InnoDB: Using atomics to ref count buffer pool pages
2016-09-25 11:20:28 2357 [Note] InnoDB: Starting shutdown...
2016-09-25 11:20:30 2357 [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
……
New default config file was created as /usr/local/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
看见两个OK则表示安装成功了。

8. 拷贝参数文件到/etc下并编辑

拷贝软件安装路径下的my.cnf到/etc下
[root@vast mysql]# cp /usr/local/mysql/my.cnf  /etc/
在文件中添加basedir、datadir、port、server_id
Basedir 软件路径
Datadir 数据文件路径
Port 端口号
Server_id 服务id
[root@vast mysql]# vi /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
[mysqld]
# 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 = /usr/local/mysql
datadir = /data/mydb
port = 3306
server_id = 1 
# 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 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

9. 建立软连接

软连接可以理解为windows的快捷方式
[root@vast mysql]# cd /usr/local/mysql/bin/
[root@vast bin]# ln -s /usr/local/mysql/bin/mysql  /usr/bin/

10. 复制mysql服务文件到初始化系统文件下

以下内容为一行内容
[root@vast bin]# cp 
/usr/local/mysql/support-files/mysql.server  /etc/init.d/mysqld

11. 开启mysqld服务

[root@vast bin]# service mysqld start
Starting MySQL. SUCCESS!

12. 登录mysql数据库

键入mysql进入mysql数据库
[root@vast bin]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.31 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, 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>

13. 查看当前存在数据库

mysql> show databases ;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)
退出mysql
mysql>exit

14. 关闭mysqld服务

[root@vast ~]# service mysqld stop
Shutting down MySQL.. SUCCESS!

15. 重启mysqld服务

[root@vast ~]# service mysqld restart
Shutting down MySQL.. SUCCESS! 
Starting MySQL. SUCCESS!

完成

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值