在centos6.5中安装mysql5.7

简介

博主最近在研究mysql的读写分离和主从复制,一台master和两台slave,三台机器在同一个局域网中,首先就就要在centos6.5中安装mysql5.7。好了,废话不多说,接下来进入正题。

一、解压缩到/usr/local/下面,mysql的主目录命名为mysql

[[email protected] local]# cd /usr/local/soft/

[[email protected] soft]# tar zvxf mysql-5.7.10-linux-glibc2.5-i686.tar.gz -C /usr/local

[[email protected] soft]# cd ..

[[email protected] local]# mv mysql-5.7.10-linux-glibc2.5-i686/ mysql

二、在mysql下面创建data数据库文件目录

[[email protected] local]# mkdir mysql/data

三、创建mysql的用户组和用户,并对mysql目录设置用户组和用户

[[email protected] local]# groupadd mysql

[[email protected] local]# useradd mysql -g mysql

[[email protected] local]# cd mysql

[[email protected] mysql]# pwd

/usr/local/mysql

[[email protected] mysql]# chown -R mysql . #给名称为mysql的用户授权

[[email protected] mysql]# chgrp -R mysql .

四、初始化mysql并启动mysql服务

[[email protected] mysql]# cd /usr/local/mysql/bin

[[email protected] bin]# yum install libaio

[[email protected] bin]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data

2016-01-09 12:00:28 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize

2016-01-09 12:00:33 [WARNING] The bootstrap log isn‘t empty:

2016-01-09 12:00:33 [WARNING] 2016-01-09T04:00:29.262989Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead

2016-01-09T04:00:29.264643Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)

2016-01-09T04:00:29.264653Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)

[[email protected] bin]# cd /usr/local/mysql/support-files

[[email protected] support-files]# ./mysql.server start

Starting MySQL. SUCCESS! 

五、登录mysql,此版本最新版不许空密码登录,实际上有个初始化密码保存在/root/.mysql_secret这个文件里面,用这个密码第一次登录后,再修改密码。因此先cat查看下初始化密码(随机的,每次安装看到的密码都不一样):

[[email protected] ~]# cat /root/.mysql_secret

# Password set for user ‘[email protected]‘ at 2016-11-10 20:19:35
2t:tRP01UZ16

#利用初始化密码:2t:tRP01UZ16 开始登录mysql:

[[email protected] ~]# cd /usr/local/mysql/bin

[[email protected] bin]# ./mysql -uroot -p:2t:tRP01UZ16

mysql: [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 5

Server version: 5.7.10
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>

显示登录成功,可以执行mysql命令操作了!

六、改mysql的root密码,新密码在此为‘admin‘

mysql> set password=password(‘admin‘);

Query OK, 0 rows affected, 1 warning (0.00 sec)

七、设定远程登录mysql。在Linux下为了安全,默认是不允许mysql本机以外的机器访问mysql数据库服务,因此需要重新授权root。方便远程访问。

mysql> use mysql;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> select Host,User from user;

+-----------+-----------+

| Host      | User      |

+-----------+-----------+

| %         | root      |

| localhost | mysql.sys |

| localhost | root      |

+-----------+-----------+

3 rows in set (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO [email protected]‘%‘ identified by ‘admin‘;

Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

授权语句最后的‘admin’是mysql数据库root用户的新密码。

八、非必要的步骤,如果远程连不上,估计是防火墙的问题,关闭试试:

[[email protected] mysql]# service iptables stop

setenforce 0iptables:将链设置为政策 ACCEPT:filter        [确定]

iptables:清除防火墙规则:                                 [确定]

iptables:正在卸载模块:                                   [确定]

[[email protected] mysql]# setenforce 0

setenforce: SELinux is disabled

九、将mysql设置为开机自启动,并添加软连接

[[email protected] mysql]# cd /usr/local/mysql/support-files/

[[email protected]localhost support-files]# cp mysql.server /etc/init.d

[[email protected]localhost support-files]# cd /etc/init.d

[[email protected]localhost init.d]# mv mysql.server mysqld

[[email protected]localhost init.d]# cd /usr/bin

[[email protected] bin]# ln -s /usr/local/mysql/bin/mysql mysql

注意问题:存放mysql解压文件路径/usr/local/mysql和存放mysql数据路径/usrl/local/mysql/data ,博主刚开始以为这个路径是自定义的,就命名为/usr/local/mysql5.7和/usrl/local/mysql5.7/data结果没安装成功了,但是启动不了,最后只能卸载了重新安装

时间: 2024-10-14 07:28:09

在centos6.5中安装mysql5.7的相关文章

在centos-6.3中安装mysql-5.5.48

采用源码编译方式在centos-6.3中安装mysql-5.5.48,编译器使用cmake. 软件包:mysql-5.5.48.tar.gz和cmake-2.8.10.2.tar.gz 软件包下载地址: http://mysql.mirror.kangaroot.net/Downloads/ 或 http://pan.baidu.com/s/1pLKOC0z http://www.cmake.org/files 或 http://pan.baidu.com/s/1slSmhAX 步骤: 1.将m

centos6.5编译安装mysql5.6.20

一.   准备工作 1     yum安装各个依赖包 [[email protected] ~]# yum –y install gcc gcc-devel gcc-c++ gcc-c++-devel  zlib*  ncurses-devel ncurses openssl openssl-devel bison bison-devel libaio [[email protected] ~]# yum –y install cmake 2.新建mysql组和用户 [[email protec

centOS6.3下安装mysql5.6详解

首先去mysql官网下载需要的linux版本的mysql,我下的是MySQL-5.6.17-1.linux_glibc2.5.x86_64.rpm-bundle.tar 下载网址为:http://dev.mysql.com/downloads/mysql/ 接下来把下载下来的mysql拖到centOS中去,也可以直接在centOS中下载. 接下来解压下载好的文件 [[email protected] src]# tar -xvf MySQL-5.6.17-1.linux_glibc2.5.x86

CentOS6、7安装MySQL5.7全教程

CentOS6.7安装MySQL5.7全教程 做开发总得用到数据吧,Linux作为服务器,总得有一个数据库来存储测试用的数据,所以呢,这里附上CentOS6.7安装MySQL5.7的教程喔~ 用到的工具:CentOs6.7:Mysql依赖包 Step1. 查看已安装的mysql: # yum list installed | grep mysql mysql-libs.x86_64 5.1.71-1.el6 @anaconda-CentOS-201311272149.x86_64/6.5 卸载当

CentOS6.8手动安装MySQL5.6

CentOS6.8手动安装MySQL5.6 众所周知,mysql5.7推出后有很多没有填好的坑,对于老的系统和项目兼容性也存在问题,所以现在普遍的web项目还是应该跑在centos6.8+mysql5.6的环境之下,今天主要说一下mysql5.6如何编译安装的具体步骤. 1.安装mysql5.6依存包 2.下载编译包 wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.

在CentOS6.4中安装配置LAMP环境的详细步骤

原文:在CentOS6.4中安装配置LAMP环境的详细步骤 本文详细介绍了CentOS6.4系统中安装LAMP服务并对其进行配置的过程,即安装Apache+PHP+Mysql,参照了网上大神的设置,其他Linux发行系统可以参考~ 在本文中部分命令操作需要root权限,输入‘su -’命令后输入密码即可切换root身份. 一.修改设置对安装做准备 1. 防火墙设置 设置/etc/sysconfig/iptables文件允许80端口和3306端口.因为80端口是http协议所使用的端口,如果防火墙

CentOs6.5中安装和配置vsftp简明教程

这篇文章主要介绍了CentOs6.5中安装和配置vsftp简明教程,需要的朋友可以参考下 一.vsftp安装篇 复制代码代码如下: # 安装vsftpdyum -y install vsftpd# 启动service vsftpd start# 开启启动chkconfig vsftpd on 二.vsftp相关命令之服务篇 复制代码代码如下: # 启动ftp服务service vsftpd start# 查看ftp服务状态service vsftpd status # 重启ftp服务servic

centos6.7编译安装mysql5.7.17

centos6.7编译安装mysql5.7.17 2017-03-24 09:57:15 提示:mysql5.7.17和之前5.56以前的版本安装不一样,需要用cmake 另外,看本文档的mysql编译前我说一点,第一次一定要大概的看完整个过程,不能一直跟着文档做,否则后面容易遇到问题.比如编译完会特别占用磁盘空间,万一之前分配的空间不够,那样就会丢失很多重要文件导致失败. 安装前工作: 1,从官方网址下载MySQL5.7.17源码包 http://dev.MySQL.com/downloads

centos6.5 rpm安装mysql5.6.19

1,检查MySQL及相关RPM包,是否安装,如果有安装,则移除. rpm -qa | grep -i mysql yum -y remove mysql-libs* 2,根据系统下载RPM包,我下载的MySQL-5.6.19-1.el6.i686.rpm-bundle.tar 解压压缩包,依次安装: rpm -ivh MySQL-server-5.6.19-1.el6.i686.rpm rpm -ivh MySQL-devel-5.6.19-1.el6.i686.rpm rpm -ivh MyS