CentOS7 安装mysql

下载 mysql-community-release

wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

过程:

[root@master targz]# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
--2016-07-27 12:10:56--  http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
Resolving dev.mysql.com (dev.mysql.com)... 137.254.60.11
Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://repo.mysql.com//mysql-community-release-el7-5.noarch.rpm [following]
--2016-07-27 12:10:57--  http://repo.mysql.com//mysql-community-release-el7-5.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 104.102.164.25
Connecting to repo.mysql.com (repo.mysql.com)|104.102.164.25|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6140 (6.0K) [application/x-redhat-package-manager]
Saving to: ‘mysql-community-release-el7-5.noarch.rpm100%[============================================================================>] 6,140       --.-K/s   in 0s

2016-07-27 12:10:57 (293 MB/s) - ‘mysql-community-release-el7-5.noarch.rpm’ saved [6140/6140]

安装 mysql-community-release

rpm -ivh mysql-community-release-el7-5.noarch.rpm

过程

[root@master targz]# rpm -ivh mysql-community-release-el7-5.noarch.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-release-el7-5    ################################# [100%]

安装 mysql-community-server

yum install mysql-community-server

过程

[root@master targz]# yum install mysql-community-server
Loaded plugins: fastestmirror, langpacks
base                                                                                           | 3.6 kB  00:00:00
epel/x86_64/metalink                                                                           | 4.4 kB  00:00:00
extras                                                                                         | 3.4 kB  00:00:00
mysql-connectors-community                                                                     | 2.5 kB  00:00:00
mysql-tools-community                                                                          | 2.5 kB  00:00:00
mysql56-community                                                                              | 2.5 kB  00:00:00
updates                                                                                        | 3.4 kB  00:00:00
(1/4): mysql-connectors-community/x86_64/primary_db                                            | 9.8 kB  00:00:00
(2/4): mysql-tools-community/x86_64/primary_db                                                 |  26 kB  00:00:00
(3/4): mysql56-community/x86_64/primary_db                                                     | 130 kB  00:00:00
(4/4): updates/7/x86_64/primary_db                                                             | 5.7 MB  00:00:19
Loading mirror speeds from cached hostfile
 * base: centos.ustc.edu.cn
 * epel: mirror.pregi.net
 * extras: centos.ustc.edu.cn
 * updates: centos.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.6.31-2.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.6.31-2.el7 for package: mysql-community-server-5.6.31-2.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) = 5.6.31-2.el7 for package: mysql-community-server-5.6.31-2.el7.x86_64
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.44-2.el7.centos will be obsoleted
---> Package mysql-community-client.x86_64 0:5.6.31-2.el7 will be obsoleting
--> Processing Dependency: mysql-community-libs(x86-64) = 5.6.31-2.el7 for package: mysql-community-client-5.6.31-2.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.6.31-2.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.44-2.el7.centos will be obsoleted
--> Processing Dependency: mariadb-libs(x86-64) = 1:5.5.44-2.el7.centos for package: 1:mariadb-devel-5.5.44-2.el7.centos.x86_64
---> Package mysql-community-libs.x86_64 0:5.6.31-2.el7 will be obsoleting
--> Running transaction check
---> Package mariadb-devel.x86_64 1:5.5.44-2.el7.centos will be obsoleted
---> Package mysql-community-devel.x86_64 0:5.6.31-2.el7 will be obsoleting
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================
 Package                            Arch               Version                    Repository                     Size
======================================================================================================================
Installing:
 mysql-community-client             x86_64             5.6.31-2.el7               mysql56-community              19 M
     replacing  mariadb.x86_64 1:5.5.44-2.el7.centos
 mysql-community-devel              x86_64             5.6.31-2.el7               mysql56-community             3.4 M
     replacing  mariadb-devel.x86_64 1:5.5.44-2.el7.centos
 mysql-community-libs               x86_64             5.6.31-2.el7               mysql56-community             2.0 M
     replacing  mariadb-libs.x86_64 1:5.5.44-2.el7.centos
 mysql-community-server             x86_64             5.6.31-2.el7               mysql56-community              59 M
Installing for dependencies:
 mysql-community-common             x86_64             5.6.31-2.el7               mysql56-community             256 k

Transaction Summary
======================================================================================================================
Install  4 Packages (+1 Dependent package)

Total download size: 84 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/mysql56-community/packages/mysql-community-common-5.6.31-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Public key for mysql-community-common-5.6.31-2.el7.x86_64.rpm is not installed
(1/5): mysql-community-common-5.6.31-2.el7.x86_64.rpm                                          | 256 kB  00:00:00
(2/5): mysql-community-devel-5.6.31-2.el7.x86_64.rpm                                           | 3.4 MB  00:00:00
(3/5): mysql-community-libs-5.6.31-2.el7.x86_64.rpm                                            | 2.0 MB  00:00:00
(4/5): mysql-community-server-5.6.31-2.el7.x86_64.rpm                                          |  59 MB  00:00:15
(5/5): mysql-community-client-5.6.31-2.el7.x86_64.rpm                                          |  19 MB  00:00:41
----------------------------------------------------------------------------------------------------------------------
Total                                                                                 2.0 MB/s |  84 MB  00:00:41
Retrieving key from file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
 Userid     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
 Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
 Package    : mysql-community-release-el7-5.noarch (installed)
 From       : file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows:
log4j-1.2.17-15.el7.noarch has missing requires of mvn(javax.mail:mail)
  Installing : mysql-community-common-5.6.31-2.el7.x86_64                                                         1/8
  Installing : mysql-community-libs-5.6.31-2.el7.x86_64                                                           2/8
  Installing : mysql-community-client-5.6.31-2.el7.x86_64                                                         3/8
  Installing : mysql-community-server-5.6.31-2.el7.x86_64                                                         4/8
  Installing : mysql-community-devel-5.6.31-2.el7.x86_64                                                          5/8
  Erasing    : 1:mariadb-devel-5.5.44-2.el7.centos.x86_64                                                         6/8
  Erasing    : 1:mariadb-5.5.44-2.el7.centos.x86_64                                                               7/8
  Erasing    : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64                                                          8/8
  Verifying  : mysql-community-devel-5.6.31-2.el7.x86_64                                                          1/8
  Verifying  : mysql-community-server-5.6.31-2.el7.x86_64                                                         2/8
  Verifying  : mysql-community-client-5.6.31-2.el7.x86_64                                                         3/8
  Verifying  : mysql-community-libs-5.6.31-2.el7.x86_64                                                           4/8
  Verifying  : mysql-community-common-5.6.31-2.el7.x86_64                                                         5/8
  Verifying  : 1:mariadb-devel-5.5.44-2.el7.centos.x86_64                                                         6/8
  Verifying  : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64                                                          7/8
  Verifying  : 1:mariadb-5.5.44-2.el7.centos.x86_64                                                               8/8

Installed:
  mysql-community-client.x86_64 0:5.6.31-2.el7              mysql-community-devel.x86_64 0:5.6.31-2.el7
  mysql-community-libs.x86_64 0:5.6.31-2.el7                mysql-community-server.x86_64 0:5.6.31-2.el7

Dependency Installed:
  mysql-community-common.x86_64 0:5.6.31-2.el7

Replaced:
  mariadb.x86_64 1:5.5.44-2.el7.centos                      mariadb-devel.x86_64 1:5.5.44-2.el7.centos
  mariadb-libs.x86_64 1:5.5.44-2.el7.centos

Complete!

配置mysql

编码

mysql配置文件为/etc/my.cnf

最后加上编码配置

[mysql]
default-character-set=utf8

这里的字符编码必须在/usr/share/mysql/charsets/Index.xml中存在并且一致。

这里写图片描述

设置密码

[root@master]# mysql -u root 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.26 MySQL Community Server (GPL)

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> set password for 'root'@'master' =password('********');
Query OK, 0 rows affected (0.00 sec)
  • master 是你的主机名称
  • password(‘**‘) 其中的*号就是你设置的密码

远程连接设置

把在所有数据库的所有表的所有权限赋值给位于所有IP地址的root用户。

mysql> grant all privileges on *.* to root@'%'identified by '******';

如果是新用户而不是root,则要先新建用户

mysql>create user 'username'@'%' identified by 'password';  

参考

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值