安装前的准备

Step1: 如果你系统已经有mysql,如一般centos自带mysql5.1系列,那么你需要删除它,先检查一下系统是否自带mysql

yum list installed | grep mysql

Step2: 删除系统自带的mysql及其依赖命令

yum -y remove mysql-libs.x86_64

Step3: 给CentOS添加rpm源,并且选择较新的源命令

wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
yum localinstall mysql-community-release-el6-5.noarch.rpm
yum repolist all | grep mysql
yum-config-manager --disable mysql55-community
yum-config-manager --disable mysql56-community
yum-config-manager --enable mysql57-community-dmr
yum repolist enabled | grep mysql

开始安装

Step4:安装mysql 服务器命令

yum install mysql-community-server

CENTOS7上安装MYSQL5.7还有一个巨坑

之前的Linux体系中数据库大局部是mysql,不外自从被sun收买以后,便出用散成正在centos那些开源Linux体系中了,那末若是念用的话便须要本身装置了,起首centos7 已没有支撑mysql。

以前的Linux系统中数据库大部分是mysql,不过自从被sun收购之后,就没用集成在centos这些开源Linux系统中了,那么如果想用的话就需要自己安装了,首先centos7 已经不支持mysql,因为收费了你懂得,所以内部集成了mariadb,而安装mysql的话会和mariadb的文件冲突,所以在运行以下命令前:

yum install mysql-community-server

需要先卸载掉mariadb,以下为卸载mariadb步骤

rpm -qa | grep mariadb

当检查出了系统自带的mariadb后如版本为:mariadb-libs-5.5.37-1.el7_0.x86_64 那么使用以下命令:

rpm -e --nodeps mariadb-libs-5.5.37-1.el7_0.x86_64

强制卸了它,再安装mysql5.7即可。

Step5: 启动mysql命令

service mysqld start

Step6: 查看mysql是否自启动,并且设置开启自启动命令

chkconfig --list | grep mysqld
chkconfig mysqld on

mysql5.7安装完后如何开启远程root包括远程用户权限

mysql5.7对于安全模块进行了升级,因此如果你想像以前那样在安装完mysql后直接以mysql -u root登录进去再通过一系列的sql命令来更改权限但是这在mysql5.7上是行不通的,按照以前的做法,你会在面临mysql5.7碰到这样的一个报错“access denied for user root@localhost” ,因此请按照以下使用说明操作。

Step1: 停止mysqld服务并使用mysqld safe启动

service mysqld stop
mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

RHEL7.0系列的发行版(例如CentOs 7),特征是使用了systemd来代替原有的init,作为第一支启动的程序。此时网络上面所说的mysqld_secure已经不可使用。但是查看官方文档后,得知在这种情况下mysqld可以支持部分mysqld_safe的参数,命令如下:

mysqld   --user=mysql --skip-grant-tables --skip-networking &

Step2:登录mysql

此时,你在mysql服务器上使用

mysql -uroot -p

就可以登录mysql了

Step3: 更改mysql安全密码

先説一下原因,mysql5.7出现这样的问题,是因为MYSQL5.6之后,加强了对安全性的管控,认为root用户进行mysql操作是一种危险的行为,于是限制了root用户登录mysql()。但是我们可以通过修改Mysql中user表的方法解决该问题
(网络上还有一种做法是查看/var/log/mysql.log,该文件内有安装后Mysql生成的随机密码,然后用文件里的密码正常登录即可,有兴趣者自己可以试下,此处使用正规操作步骤)

mysql> SET PASSWORD = PASSWORD('ur password here');

如果出现以下信息:

ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement 

请先运行

update mysql.user set authentication_string=password('newpassword') where user='root'

Step4:更改mysql root的密码(和Step3中保持一致)

update mysql.user set authentication_string=password('newpassword') where user='root'

之前的mysql版本为:

UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
flush privileges;

而mysql5.7已经把PASSWORD字段改名成了"authentication_string"这个名字了,此处需要注意了。

Step5:建立可供远程连接的root用户

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'ur password here' WITH GRANT OPTION;

Step6:在远程装个mysql workbench然后用远程root登录,爱干吗干吗吧

MYSQL核心配置文件示例

虚拟CPU 6C
内存:6GB
优化过的配置如下:

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/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
#
# 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 = 6M
read_rnd_buffer_size = 4M #deprecate this option after mysql5.5 default-character-set = utf8 character-set-server=utf8
open_files_limit = 10240
back_log = 384
max_connections = 500
#deprecate this option after mysql5.5 table_cache = 512K
max_allowed_packet =16M
query_cache_size = 384M
table_open_cache = 512
key_buffer_size = 384M datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock # Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0 log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid slow_query_log_file = /var/log/mysqld-slow-query.log
log-short-format
long-query-time = 3
#log-long-format
#log-slow-admin-statements
log-queries-not-using-indexes

mysql5.7在centos上安装的完整教程以及相关的“坑”的更多相关文章

  1. centOS上安装MySQL5.7

    在centos上安装mysql,前提得有sudo的权限.没有的话先去跟管理员申请一个. STEP 1 - 安装MySQL 首先打开浏览器访问下 https://dev.mysql.com/downlo ...

  2. 在Centos上安装RabbitMQ流程(转)

    在Centos上安装RabbitMQ流程------------------------ 1. 需求 由于项目中要用到消息队列,经过ActiveMQ与RabbitMQ的比较,最终选择了RabbbitM ...

  3. 在centos上安装mysql

    本文依然是用的xftp上传gz文件,然后在xShell上操作的,如果没有安装使用这两个文件的请查阅之前的博客. 1.将下载好的文件用xftp上传到对应的位置. 2.解压文件:tar  -zvxf  m ...

  4. centos上安装python环境

    1.安装python-pip ​ 首先安装epel扩展源: ​ yum -y install epel-release ​ 更新完成之后,安装pip: ​ yum -y install python- ...

  5. NoSql1 在Linux(CentOS)上安装memcached及使用

    前言:       今天是初五,生活基本要从过年的节奏中回归到正常的生活了,所以想想也该想想与工作有关的事情了.我之前在工作中会经常使用memcached和redis,但是自己一直没有时间系统的好好看 ...

  6. 在Ubuntu|CentOS上安装Shutter截图工具及快捷键设置

    简介 Shutter前身叫GScrot,它是一款相当棒的截图软件. 通过Shutter,你可以截取包括选定区域.全屏幕.窗口.窗口内的控件甚至网页的图像.通过内置的强大插件机制,你可以在截图后,对图像 ...

  7. 在CentOS上安装rabbitmq-server

    ***在 CentOS 6.4上安装python*** 注意啊,自己手动安装python2.7.5,不要动系统上面其他的版本 1,先安装GCC,用如下命令yum install gcc gcc-c++ ...

  8. CentOS上安装软件错误提示:configure: error: no acceptable C compiler found in $PATH

    CentOS上安装软件错误提示:configure: error: no acceptable C compiler found in $PATH 因为是centos linux,默认可以采用yum方 ...

  9. 如何在centos上安装epel源

    一.EPEL是什么? EPEL (Extra Packages for Enterprise Linux,企业版Linux的额外软件包) 是Fedora小组维护的一个软件仓库项目,为RHEL/Cent ...

随机推荐

  1. 在 .NET Core 中使用 DiagnosticSource 记录跟踪信息

    前言 最新一直在忙着项目上的事情,很久没有写博客了,在这里对关注我的粉丝们说声抱歉,后面我可能更多的分享我们在微服务落地的过程中的一些经验.那么今天给大家讲一下在 .NET Core 2 中引入的全新 ...

  2. 遗传算法详解(LINGO及MatlabGA工具箱求解实现)

    遗传算法 1.前言 遗传算法是一种基于生物界自然群体遗传进化机制的自适应全局优化概率搜索算法.它与传统算法不同,不依赖梯度信息,而是通过模拟自然进化过程来搜索最优解. 例子:兔子的遗传进化 有人说,现 ...

  3. [LeetCode] Find Duplicate File in System 在系统中寻找重复文件

    Given a list of directory info including directory path, and all the files with contents in this dir ...

  4. pyqt5 动画学习(四) 旋转动画,使用QGraphicsView让自己的控件旋转起来

    今天学有所成,赶紧记下今天的成果 之前三篇文章分别演示了空间的大小改变,移动,及颜色变化.在后续研究旋转的过程中即为艰难 如果你是使用pyqt4,那么使用QGraphicsItemAnimation便 ...

  5. hadoop一键安装伪分布式

    hadoop伪分布式和hive在openSUSE中的安装 在git上的路径为:https://github.com/huabingood/hadoop--------/tree/master 各个文件 ...

  6. LeetCode题目----求中位数---标签:Array

    题目难度---困难 题目要求: 给定两个大小为 m 和 n 的有序数组 nums1 和 nums2 . 请找出这两个有序数组的中位数.要求算法的时间复杂度为 O(log (m+n)) . 思路:第一眼 ...

  7. JS点击按钮打开新的独立页面

    工作中遇到需要点击按钮弹出一个独立的页面,并显示指定内容的问题,查了一些资料后,得到以下方法: window.open('locationPage.html', '_blank', 'height=1 ...

  8. 推送本地项目至Github遇到的问题以及解决办法记录

    在把本地新项目推送至GitHub仓库时的大致流程和步骤,首先现在GitHub上面新建一个项目,复制该项目的 带.git 后缀的地址,比如 git@github.com:XXX/XXX.git 然后在本 ...

  9. [POJ 3487]The Stable Marriage Problem

    Description The stable marriage problem consists of matching members of two different sets according ...

  10. [HAOI2007]分割矩阵

    题目描述 将一个a*b的数字矩阵进行如下分割:将原矩阵沿某一条直线分割成两个矩阵,再将生成的两个矩阵继续如此分割(当然也可以只分割其中的一个),这样分割了(n-1)次后,原矩阵被分割成了n个矩阵.(每 ...