centos7使用MySQL的Yum存储库安装mysql5.6.45
注意:这个MySQL5.6.45版本有问题,修改配置文件不生效,推荐安装MySQL5.6.43
下载yum源
官网地址:http://dev.mysql.com/downloads/repo/yum/
centos7系统:
wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
[root@localhost ~]# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
---- ::-- http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 104.74.21.42
Connecting to repo.mysql.com (repo.mysql.com)|104.74.21.42|:... connected.
HTTP request sent, awaiting response... OK
Length: (.0K) [application/x-redhat-package-manager]
Saving to: ‘mysql-community-release-el7-.noarch.rpm’ %[===================================================================================================================>] , --.-K/s in 0s -- :: ( MB/s) - ‘mysql-community-release-el7-.noarch.rpm’ saved [/] [root@localhost ~]#
[root@localhost ~]# ls
anaconda-ks.cfg mysql-community-release-el7-.noarch.rpm
centos6.5系统:
wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
wget http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm
检测系统是否自带安装mysql
# yum list installed | grep mysql
删除系统自带的mysql
# yum -y remove mysql-libs.x86_64
由于这个mysql的yum源服务器在国外,所以下载速度会比较慢,mysql5.6只有79M大,而mysql5.7就有182M。
安装mysql-community-release-el7-5.noarch.rpm包
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
[root@localhost ~]# rpm -ivh mysql-community-release-el7-.noarch.rpm
Preparing... ################################# [%]
Updating / installing...
:mysql-community-release-el7- ################################# [%]
安装完这个包后,会获得两个mysql的yum repo源:/etc/yum.repos.d/mysql-community.repo,/etc/yum.repos.d/mysql-community-source.repo
[root@localhost ~]# ls /etc/yum.repos.d/
centos.repo mysql-community.repo mysql-community-source.rep
# vi mysql-community.repo
[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/7/$basearch/
enabled=
gpgcheck=
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [mysql-tools-community]
name=MySQL Tools Community
baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/7/$basearch/
enabled=
gpgcheck=
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql # Enable to use MySQL 5.5
[mysql55-community]
name=MySQL 5.5 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/7/$basearch/
enabled=
gpgcheck=
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql # Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/
enabled=
gpgcheck=
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql # Note: MySQL 5.7 is currently in development. For use at your own risk.
# Please read with sub pages: https://dev.mysql.com/doc/relnotes/mysql/5.7/en/
[mysql57-community-dmr]
name=MySQL 5.7 Community Server Development Milestone Release
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=
gpgcheck=
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
# cat mysql-community-source.repo
[root@localhost yum.repos.d]# cat mysql-community-source.repo
[mysql-connectors-community-source]
name=MySQL Connectors Community - Source
baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/7/SRPMS
enabled=
gpgcheck=
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [mysql-tools-community-source]
name=MySQL Tools Community - Source
baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/7/SRPMS
enabled=
gpgcheck=
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [mysql55-community-source]
name=MySQL 5.5 Community Server - Source
baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/7/SRPMS
enabled=
gpgcheck=
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [mysql56-community-source]
name=MySQL 5.6 Community Server - Source
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/SRPMS
enabled=
gpgcheck=
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [mysql57-community-dmr-source]
name=MySQL 5.7 Community Server Development Milestone Release - Source
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/SRPMS
enabled=
gpgcheck=
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
用yum repolist mysql这个命令查看一下是否已经有mysql可安装文件
# yum repolist all | grep mysql
[root@localhost ~]# yum repolist all | grep mysql
mysql-connectors-community/x86_64 MySQL Connectors Community enabled:
mysql-connectors-community-source MySQL Connectors Community - S disabled
mysql-tools-community/x86_64 MySQL Tools Community enabled:
mysql-tools-community-source MySQL Tools Community - Source disabled
mysql55-community/x86_64 MySQL 5.5 Community Server disabled
mysql55-community-source MySQL 5.5 Community Server - S disabled
mysql56-community/x86_64 MySQL 5.6 Community Server enabled:
mysql56-community-source MySQL 5.6 Community Server - S disabled
mysql57-community-dmr/x86_64 MySQL 5.7 Community Server Dev disabled
mysql57-community-dmr-source MySQL 5.7 Community Server Dev disabled
安装mysql
# yum install mysql-server -y
Installed:
mysql-community-libs.x86_64 :5.6.-.el7 mysql-community-server.x86_64 :5.6.-.el7 Dependency Installed:
mysql-community-client.x86_64 :5.6.-.el7 mysql-community-common.x86_64 :5.6.-.el7 net-tools.x86_64 :2.0-0.24.20131004git.el7
perl-Compress-Raw-Bzip2.x86_64 :2.061-.el7 perl-Compress-Raw-Zlib.x86_64 :2.061-.el7 perl-DBI.x86_64 :1.627-.el7
perl-IO-Compress.noarch :2.061-.el7 perl-Net-Daemon.noarch :0.48-.el7 perl-PlRPC.noarch :0.2020-.el7 Replaced:
mariadb-libs.x86_64 :5.5.-.el7.centos Complete!
加入开机自启动
# systemctl enable mysqld
启动mysql服务进程
# systemctl start mysqld
查看mysql服务进程
# systemctl status mysqld
[root@localhost ~]# systemctl enable mysqld
[root@localhost ~]#
[root@localhost ~]# systemctl start mysqld
[root@localhost ~]#
[root@localhost ~]# systemctl status mysqld
â— mysqld.service - MySQL Community Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Sat -- :: CST; 13s ago
Process: ExecStartPost=/usr/bin/mysql-systemd-start post (code=exited, status=/SUCCESS)
Process: ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=/SUCCESS)
Main PID: (mysqld_safe)
CGroup: /system.slice/mysqld.service
├─ /bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─ /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mysqld.log --pid-fil... Aug :: localhost.localdomain mysql-systemd-start[]: PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
Aug :: localhost.localdomain mysql-systemd-start[]: To do so, start the server, then issue the following commands:
Aug :: localhost.localdomain mysql-systemd-start[]: /usr/bin/mysqladmin -u root password 'new-password'
Aug :: localhost.localdomain mysql-systemd-start[]: /usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
Aug :: localhost.localdomain mysql-systemd-start[]: Alternatively you can run:
Aug :: localhost.localdomain mysql-systemd-start[]: /usr/bin/mysql_secure_installation
Aug :: localhost.localdomain mysql-systemd-start[]: which will also give you the option of removing the test
Aug :: localhost.localdomain mysqld_safe[]: :: mysqld_safe Logging to '/var/log/mysqld.log'.
Aug :: localhost.localdomain mysqld_safe[]: :: mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Aug :: localhost.localdomain systemd[]: Started MySQL Community Server.
进入mysql
# mysql
[root@localhost ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.6. MySQL Community Server (GPL) Copyright (c) , , 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_secure_installation
[root@localhost ~]# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here. Enter current password for root (enter for none): #回车
OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation. Set root password? [Y/n] y #是否设置root密码
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success! By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment. Remove anonymous users? [Y/n] y #是否删除匿名用户
... Success! Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] n #是否禁止root用户远程登录
... skipping. By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment. Remove test database and access to it? [Y/n] y #是否删除test数据库
- Dropping test database...
ERROR (HY000) at line : Can't drop database 'test'; database doesn't exist
... Failed! Not critical, keep moving...
- Removing privileges on test database...
... Success! Reloading the privilege tables will ensure that all changes made so far
will take effect immediately. Reload privilege tables now? [Y/n] y #是否刷新权限配置生效
... Success! All done! If you've completed all of the above steps, your MySQL
installation should now be secure. Thanks for using MySQL! Cleaning up...
再次进入mysql会出现如下情况
# mysql
[root@localhost ~]# mysql
ERROR (): Access denied for user 'root'@'localhost' (using password: NO)
使用用户名密码进入mysql
# mysql -uroot -p
[root@localhost ~]# mysql -uroot -p
Enter password: #输入设置的root密码
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.6. MySQL Community Server (GPL) Copyright (c) , , 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只允许内部使用连接,客户端连接会报如下错误
null, message from server: "Host '192.168.1.10' is not allowed to connect to this MySQL server"
授权远程登录
grant all privileges on *.* to root@'%' identified by 'password' with grant option;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY 'password' WITH GRANT OPTION;
第一个是你的用户名root,第二个password是远程的密码
mysql> grant all privileges on *.* to root@'%' identified by '123456' with grant option
mysql> flush privileges;
mysql> select user,host,password from mysql.user;
+------+-----------------------+-------------------------------------------+
| user | host | password |
+------+-----------------------+-------------------------------------------+
| root | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | localhost.localdomain | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | 127.0.0.1 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | :: | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+------+-----------------------+-------------------------------------------+
rows in set (0.00 sec) mysql> grant all privileges on *.* to root@'%' identified by '' with grant option;
Query OK, rows affected (0.00 sec) mysql> flush privileges;
Query OK, rows affected (0.00 sec) mysql> select user,host,password from mysql.user;
+------+-----------------------+-------------------------------------------+
| user | host | password |
+------+-----------------------+-------------------------------------------+
| root | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | localhost.localdomain | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | 127.0.0.1 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | :: | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | % | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+------+-----------------------+-------------------------------------------+
rows in set (0.01 sec) mysql>
开放防火墙端口
# firewall-cmd --add-port 3306/tcp
# firewall-cmd --add-port 3306/tcp --permanent
[root@localhost ~]# firewall-cmd --add-port /tcp
success
重启防火墙
# systemctl restart firewalld
参考博客:
Centos7安装mysql5.6教程
https://blog.csdn.net/wyj19950908/article/details/79684574
CentOS 6.7下MySQL 5.6快速安装及参数详解
https://www.linuxidc.com/Linux/2017-11/148266.htm
centos6.5安装mysql请参考
linux CentOS6.5 yum安装mysql 5.6
CentOS7安装mysql5.6
https://blog.csdn.net/weixin_37650458/article/details/84105489
二进制编译安装mysql5.6请参考:
https://www.cnblogs.com/yszd/p/10178253.html
https://blog.51cto.com/holy2010/2287884
centos7使用MySQL的Yum存储库安装mysql5.6.45的更多相关文章
- centos7使用MySQL的Yum存储库安装mysql5.7.27
下载yum源 官网地址:http://dev.mysql.com/downloads/repo/yum/ centos7系统: http://dev.mysql.com/get/mysql57-com ...
- MySQL Yum存储库 安装、升级、集群
添加MySQL Yum存储库 首先,将MySQL Yum存储库添加到系统的存储库列表中.按着这些次序: 在http://dev.mysql.com/downloads/repo/yum/上转到MySQ ...
- 使用MySQL Yum存储库的快速指南【mysql官方文档】
使用MySQL Yum存储库的快速指南 抽象 MySQL Yum存储库提供用于在Linux平台上安装MySQL服务器,客户端和其他组件的RPM包.这些软件包还可以升级和替换从Linux发行版本机软件存 ...
- CentOS设置yum存储库 (nginx)
要为RHEL / CentOS设置yum存储库,请创建/etc/yum.repos.d/nginx.repo 使用以下内容命名的文件 : [nginx] name=nginx repo baseurl ...
- Linux系统 Centos7/Centos6.8 yum命令在线安装 MySQL5.6
Linux系统 Centos7 yum命令在线安装 MySQL5.6 标签: centosmysqlyum 2015-11-18 17:21 707人阅读 评论(0) 收藏 举报 分类: Linux ...
- Centos7安装mysql缺乏yum源怎么安装
找到mysql5.6的centos的repo源,终于解决mysql的安装问题: 1.确保centos安装了wget,没有的话安装wget 1 yum install wget 2.下载mysql的 ...
- RHEL8 创建本地YUM存储库
yum 的好处及本地yum的好处不在本文讨论范畴,本文针对rhel8中的新功能yum做简要介绍和配置,在 RHEL 8中分为两个存储库: BaseOS 应用程序流(AppStream) BaseOS中 ...
- centos7和centos6.5环境rpm方式安装mysql5.7和mysql5.6详解
centos环境安装mysql5.7 其实不建议安装mysql5.7 语法和配置可能和以前的版本区别较大,多坑,慎入 1.yum方式安装(不推荐) a.安装mysql5.7 yum源 centos6: ...
- Centos7系统下以RPM方式如何安装mysql-5.7
检查系统是否装有mariadb rpm -qa | grep mariadb 卸载mariadb 强制卸载mariadb rpm -e --nodeps mariadb-libs-5.5.35-3.e ...
随机推荐
- 本地Git绑定Gitee仓库
前言 Window的小伙伴如果还没在本地配好Git环境可以参考:https://www.cnblogs.com/poloyy/p/12185132.html 创建Gitee仓库 Gitee绑定本地Gi ...
- $.fn.serializeObject对为disabled属性的失效
问题现象: 在查生产tomcat下的localhost日志时,发现今天的记录有不少次都报org.apache.ibatis.exceptions.TooManyResultsException: Ex ...
- GitHub高级搜索指南
还在为自学时找不到适合练手的项目而苦恼? 还在好奇别人是如何在GitHub众多项目中找到高质量代码的? 真的是因为他们独具慧眼吗? 不,其实他们只是掌握了正确的搜索方法. 下面介绍几种常用的GitHu ...
- python 继承机制(子类化内置类型)
1. 如果想实现与某个内置类型具有类似行为的类时,最好的方法就是将这个内置类型子类化. 2. 内置类型子类化,其实就是自定义一个新类,使其继承有类似行为的内置类,通过重定义这个新类实现指定的功能. c ...
- Mysql 8+ 版本完全踩坑记录
问题是这样 刚霍霍了一台腾讯云服务器需要安装mysql 然后就选择了8+这个版本. 安装步骤网上有的是. 我只写最主要的部分 绝对不出错 外网可访问 .net java都可以调用 其实不指望有人看 就 ...
- SuperSocket Code解析
SuperSocket1.6Code解析 Normal Socket System.Net.Sockets.dll程序集中使用socket类: 服务器: 创建socket:_socket = new ...
- (转)GET来的漏洞
转自呆子不开口在wooyun知识库的文章 0x00 前言 这篇文章主要讲目前互联网上get方法被不规范使用带来的一些安全漏洞.其中重点会讲get请求在账号登陆体系中被滥用的场景和攻击方式. 0x01 ...
- linux--->PHP常用模块解析
PHP常用模块解析 php-gd :GD库是php处理图形的扩展库,GD库提供了一系列用来处理图片的API,使用GD库可以处理图片,或者生成图片,也可以给图片加水印 php-ldap :LDAP是轻量 ...
- linux--->用户管理和sudo权限
linux 用户 配置文件 linux主要通过用户配置文件来查看和修改用户信息 etc/passwd 第一个字段:用户名 第二个字段:密码标志 (表明这个用户有密码,密码放在etc/shadow文件) ...
- tarjan求割点与割边
tarjan求割点与割边 洛谷P3388 [模板]割点(割顶) 割点 解题思路: 求割点和割点数量模版,对于(u,v)如果low[v]>=dfn[u]那么u为割点,特判根结点,若根结点子树有超过 ...