背景:

今天才申请了腾讯云+校园计划的1元服务器,(https://www.qcloud.com/event/qcloudSchool)安装了Centos7.0,在安装mysql的时候,使用yum list | grep mysql 来查找yum源中是否有mysql,结果如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
<code class="hljs avrasm">[root@VM_47_56_centos ~]# yum list | grep mysql
akonadi-mysql.x86_64                    1.9.2-4.el7                    base    
apr-util-mysql.x86_64                   1.5.2-6.el7                    base      
mysql-proxy.x86_64                      0.8.5-2.el7                    epel    
mysql-proxy-devel.x86_64                0.8.5-2.el7                    epel    
mysql-router.x86_64                     2.0.2-1.el7                    mysql-tools-community
mysql-router-debuginfo.x86_64           2.0.2-1.el7                    mysql-tools-community
mysql-utilities.noarch                  1.5.6-1.el7                    mysql-tools-community
mysql-utilities-extra.noarch            1.5.6-1.el7                    mysql-tools
mysqlreport.noarch                      3.5-11.el7                     epel    
mysqltuner.noarch                       1.2.0-7.el7                    epel    
省略部分内容。。。。
[root@VM_47_56_centos ~]# </code>

总之是看不到mysql-server的影子,(PS:据说Centos7.0的源中暂时还没有mysql,但是相同版本的Centos在阿里云是可以直接使用yum install mysql-server 来直接安装mysql的)

于是找了一些mysql的安装源,安装过程如下:

安装过程:

为了解决这个问题,我们要先下载mysql的repo源。

1、下载mysql的repo源

1
<code class="hljs avrasm"><code class="hljs avrasm">$ wget https://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm</code></code>

2、安装mysql-community-release-el7-5.noarch.rpm包

1
<code class="hljs avrasm"><code class="hljs avrasm"><code class="hljs lasso">$ sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm</code></code></code>

安装这个包后,会获得两个mysql的yum repo源:
/etc/yum.repos.d/mysql-community.repo和
/etc/yum.repos.d/mysql-community-source.repo。

3、安装mysql

1
<code class="hljs avrasm"><code class="hljs avrasm"><code class="hljs lasso"><code class="hljs bash">$ sudo yum install mysql-server</code></code></code></code>

这个过程中就会看到有mysql的软件包存在:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<code class="hljs avrasm"><code class="hljs avrasm"><code class="hljs lasso"><code class="hljs bash"><code class="hljs asciidoc">[root@VM_47_56_centos ~]# sudo yum install mysql-server
已加载插件:fastestmirror, langpacks                  
| 2.5 kB  00:00:00    
mysql-tools-community                                                                  | 2.5 kB  00:00:00    
mysql56-community                                                                         | 2.5 kB  00:00:00    
(1/3): mysql-connectors-community/x86_64/primary_db                                       | 8.6 kB  00:00:00    
(2/3): mysql-tools-community/x86_64/primary_db                                            |  22 kB  00:00:00    
(3/3): mysql56-community/x86_64/primary_db                                                | 109 kB  00:00:01    
Loading mirror speeds from cached hostfile
 * base: mirrors.sina.cn
 * extras: mirrors.sina.cn
 * updates: mirrors.sina.cn
正在解决依赖关系
--> 正在检查事务
 
省略内容。。。
 
依赖关系解决
=================================================================================================================
 Package                           架构             版本                       源                           大小
=================================================================================================================
正在安装:
 mysql-community-libs              x86_64           5.6.27-2.el7               mysql56-community           2.0 M
      替换  mariadb-libs.x86_64 1:5.5.44-1.el7_1
 mysql-community-server            x86_64           5.6.27-2.el7               mysql56-community            58 M
为依赖而安装:
 mysql-community-client            x86_64           5.6.27-2.el7               mysql56-community            19 M
 mysql-community-common            x86_64           5.6.27-2.el7               mysql56-community           256 k
 numactl-libs                      x86_64           2.0.9-5.el7_1             
 
事务概要
=================================================================================================================
安装  2 软件包 (+9 依赖软件包)
 
总下载量:80 M
Is this ok [y/d/N]: y</code></code></code></code></code>

下边的安装和其他安装一样,

根据步骤安装就可以了,不过安装完成后,没有密码,需要重置密码。

4、重置密码

重置密码前,首先要登录

1
<code class="hljs avrasm"><code class="hljs avrasm"><code class="hljs lasso"><code class="hljs bash"><code class="hljs asciidoc"><code class="hljs ruby">$ mysql -u root</code></code></code></code></code></code>

登录时有可能报这样的错:ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘ (2),原因是/var/lib/mysql的访问权限问题。下面的命令把/var/lib/mysql的拥有者改为当前用户:

1
<code class="hljs avrasm"><code class="hljs avrasm"><code class="hljs lasso"><code class="hljs bash"><code class="hljs asciidoc"><code class="hljs ruby"><code class="hljs bash">$ sudo chown -R mysql:mysql /var/lib/mysql #这里的mysql是用户名(需要设置用户组合用户)</code></code></code></code></code></code></code>

然后,重启服务:

1
<code class="hljs avrasm"><code class="hljs avrasm"><code class="hljs lasso"><code class="hljs bash"><code class="hljs asciidoc"><code class="hljs ruby"><code class="hljs bash"><code class="hljs ruby">$ service mysqld restart</code></code></code></code></code></code></code></code>

接下来登录重置密码:

1
2
3
4
<code class="hljs avrasm"><code class="hljs avrasm"><code class="hljs lasso"><code class="hljs bash"><code class="hljs asciidoc"><code class="hljs ruby"><code class="hljs bash"><code class="hljs ruby"><code class="hljs php">$ mysql -u root
mysql > use mysql;
mysql > update user set password=password('xu827928') where user='root';
mysql > exit;</code></code></code></code></code></code></code></code></code>

5、开放3306端口(可以不用设置)

1
<code class="hljs avrasm"><code class="hljs avrasm"><code class="hljs lasso"><code class="hljs bash"><code class="hljs asciidoc"><code class="hljs ruby"><code class="hljs bash"><code class="hljs ruby"><code class="hljs php"><code class="hljs bash">$ sudo vim /etc/sysconfig/iptables</code></code></code></code></code></code></code></code></code></code>

添加以下内容:

1
<code class="hljs avrasm"><code class="hljs avrasm"><code class="hljs lasso"><code class="hljs bash"><code class="hljs asciidoc"><code class="hljs ruby"><code class="hljs bash"><code class="hljs ruby"><code class="hljs php"><code class="hljs bash"><code class="hljs lasso">-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT</code></code></code></code></code></code></code></code></code></code></code>

保存后重启防火墙:

1
<code class="hljs avrasm"><code class="hljs avrasm"><code class="hljs lasso"><code class="hljs bash"><code class="hljs asciidoc"><code class="hljs ruby"><code class="hljs bash"><code class="hljs ruby"><code class="hljs php"><code class="hljs bash"><code class="hljs lasso"><code class="hljs bash">$ sudo service iptables restart</code></code></code></code></code></code></code></code></code></code></code></code>

这样从其它客户机也可以连接上mysql服务了。

6、修改权限可以使其他机器登录:

1
2
3
4
<code class="hljs avrasm"><code class="hljs avrasm"><code class="hljs lasso"><code class="hljs bash"><code class="hljs asciidoc"><code class="hljs ruby"><code class="hljs bash"><code class="hljs ruby"><code class="hljs php"><code class="hljs bash"><code class="hljs lasso"><code class="hljs bash"><code class="hljs lasso">?mysql>mysql -h localhost -u root  //这样应该可以进入MySQL服务器
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION  //赋予任何主机访问数据的权限
mysql>FLUSH PRIVILEGES //修改生效
mysql>EXIT //退出MySQL服务器</code></code></code></code></code></code></code></code></code></code></code></code></code>

腾讯云CentOS7.0使用yum安装mysql的更多相关文章

  1. 腾讯云服务器centos通过yum安装mysql数据库

    安装mysql有两种: 1-可以使用yum安装, 2-可以自己下载安装包安装mysql, 腾讯云的centos系统自带了yum,所以用yum安装方便点 安装步骤 1-查看yum源中是否有mysql y ...

  2. centos7下使用yum安装mysql

    CentOS7的yum源中默认好像是没有mysql的.为了解决这个问题,我们要先下载mysql的repo源. 1. 下载mysql的repo源 wget http://repo.mysql.com/m ...

  3. [腾讯云]简单在腾讯云 CenTOS7.0 安装Nginx,Mysql(MariaDB),Memcache,解析PHP!

    1.安装LNMP之前要安装EPEL,以便安装源以外的软件,如Nginx,phpMyAdmin等. yum install epel-release 2.安装Nginx a) yum install n ...

  4. MySQL-5.7.19 在阿里云 CentOS-7.0 上的安装

    工具准备 查看系统是否安装了yum工具: [root@wangbo srv]# rpm -qa | grep yum yum-metadata-parser-1.1.4-10.el7.x86_64 y ...

  5. centos7.2的yum安装mysql和修改初始密码

    一.centos7.2安装mysql CentOS 7之后的版本yum的默认源中使用MariaDB替代原先MySQL,因此安装方式较为以往有一些改变: 下载mysql的源 wget http://de ...

  6. centos7.4通过yum安装mysql

    安装环境:CentOS7 64位 MINI版,安装MySQL5.7 1.配置YUM源 在MySQL官网中下载YUM源rpm安装包:http://dev.mysql.com/downloads/repo ...

  7. 转载:centos7下使用yum安装mysql

    转自:http://www.cnblogs.com/hwd-cnblogs/p/5213337.html CentOS7的yum源中默认好像是没有mysql的.为了解决这个问题,我们要先下载mysql ...

  8. centos7下使用yum安装mysql数据库以及设置远程访问

    CentOS7的yum源中默认好像是没有mysql的.为了解决这个问题,我们要先下载mysql的repo源. 1. 下载mysql的repo源 $ wget http://repo.mysql.com ...

  9. centos7上使用yum安装mysql

    centos yum是没有mysql的,集成的是新的Mariadb,怎么用yum的方式在centos7上安装mysql呢? 1. 下载mysql的repo源 wget http://repo.mysq ...

随机推荐

  1. Asp.net GridView转换成DataTable

    GridView绑定DataTable后,如何获取GridView绑定后显示的值,在项目需求需要的背景下,搜索了获取单元格显示文本的方法,然后写了一个静态方法,经过在项目中的使用,bug的修复,较为稳 ...

  2. C#基础第八天-作业-设计类-面向对象方式实现两个帐户之间转账

    要求1:完成以下两种账户类型的编码.银行的客户分为两大类:储蓄账户(SavingAccount)和信用账户(CreditAccount),两种的账户类型的区别在于:储蓄账户不允许透支,而信用账户可以透 ...

  3. 关于解决多台linux服务器间的文件实时同步问题

    最近要做一个相关的解决方案,在虚拟机测试没有问题.给大家分享出来,有更好的解决方案,欢迎讨论. 1.1 inotify相关介绍 1.rsync 与传统的cp.tar备份方式相比,rsync具有安全性高 ...

  4. 集群扩容的常规解决:一致性hash算法

    写这篇博客是因为之前面试的一个问题:如果memcached集群需要增加机器或者减少机器,那么其他机器上的数据怎么办? 最后了解到使用一致性hash算法可以解决,下面一起来学习下吧. 声明与致谢: 本文 ...

  5. 用原生JavaScript写AJAX

    //原生js写ajax就像打电话 //打电话分下面4步//1.拿出手机//2.拨号//3.说话//4.听对方说话 //ajax也分下面4步//1.创建ajax对象//2.连接到服务器//3.发送请求( ...

  6. Unity投影器细节整理

    抽了个空整理下投影器 一般投影器需要两张贴图,一张Cookie,一张FallOff. Unity提供Light和Multiple两种自带shader,和粒子类似. Cookie需要非alpha贴图,F ...

  7. RSA公钥加密,私钥解密的程序示例

    using System;using System.Collections.Generic;using System.Linq;using System.Security.Cryptography;u ...

  8. hdu 2680 Choose the best route (dijkstra算法)

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=2680 /************************************************* ...

  9. 服务器有无中木马前期诊断 注意:wget最好是从服务器上卸载掉,因为多数情况是wget下载木马到服务器的

    # rpm -qf /usr/bin/wget wget-.el6_6..x86_64 rpm -e --nodeps wget 有无下列文件: cat /etc/rc.d/init.d/selinu ...

  10. Word实用教程——五分钟教你如何在任意页开始添加页码

    最近在写一篇论文,但是在排版上遇到一点小问题,就是要加入页码,而且页码是从目录的下一页开始计数,于是我就在网上找如何在任意页添加页码.后来辗转终于搞定,真心觉得这一个小功能让微软做的如此的麻烦,真是活 ...