CentOS7 下的mysql安装与配置

之前虽然也安装过多次mysql,但每次都会遇到各种小问题,这次记录下来,以备后查。

首先是下载与安装

# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
# yum install mysql-community-server

安装过程中间会出现选择y/n的,直接输入y即可,如下:

[[email protected] /]# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
--2017-10-21 22:59:14--  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... 301 Moved Permanently
Location: https://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm [following]
--2017-10-21 22:59:14--  https://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://repo.mysql.com//mysql-community-release-el7-5.noarch.rpm [following]
--2017-10-21 22:59:16--  https://repo.mysql.com//mysql-community-release-el7-5.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 23.219.33.198
Connecting to repo.mysql.com (repo.mysql.com)|23.219.33.198|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6140 (6.0K) [application/x-redhat-package-manager]
Saving to: 鈓ysql-community-release-el7-5.noarch.rpm?

100%[====================================================================================================>] 6,140       --.-K/s   in 0s      

2017-10-21 22:59:16 (761 MB/s) - 鈓ysql-community-release-el7-5.noarch.rpm?saved [6140/6140]

[[email protected] /]# rpm -ivh mysql-community-release-el7-5.noarch.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-release-el7-5    ################################# [100%]
[[email protected] /]# yum install mysql-community-server
Loaded plugins: fastestmirror, langpacks
base                                                                                                                   | 3.6 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/7): base/7/x86_64/group_gz                                                                                          | 156 kB  00:00:00
(2/7): extras/7/x86_64/primary_db                                                                                      | 110 kB  00:00:00
(3/7): mysql-connectors-community/x86_64/primary_db                                                                    |  16 kB  00:00:03
(4/7): mysql-tools-community/x86_64/primary_db                                                                         |  35 kB  00:00:03
(5/7): updates/7/x86_64/primary_db                                                                                     | 2.9 MB  00:00:03
(6/7): base/7/x86_64/primary_db                                                                                        | 5.7 MB  00:00:08
(7/7): mysql56-community/x86_64/primary_db                                                                             | 179 kB  00:00:23
Determining fastest mirrors
 * base: mirrors.btte.net
 * extras: mirrors.163.com
 * updates: mirrors.sohu.com
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.6.38-2.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.6.38-2.el7 for package: mysql-community-server-5.6.38-2.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.6.10 for package: mysql-community-server-5.6.38-2.el7.x86_64
--> Processing Dependency: perl(DBI) for package: mysql-community-server-5.6.38-2.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.6.38-2.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.6.10 for package: mysql-community-client-5.6.38-2.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.6.38-2.el7 will be installed
---> Package perl-DBI.x86_64 0:1.627-4.el7 will be installed
--> Processing Dependency: perl(RPC::PlServer) >= 0.2001 for package: perl-DBI-1.627-4.el7.x86_64
--> Processing Dependency: perl(RPC::PlClient) >= 0.2000 for package: perl-DBI-1.627-4.el7.x86_64
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.35-3.el7 will be obsoleted
---> Package mysql-community-libs.x86_64 0:5.6.38-2.el7 will be obsoleting
---> Package perl-PlRPC.noarch 0:0.2020-14.el7 will be installed
--> Processing Dependency: perl(Net::Daemon) >= 0.13 for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Test) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Log) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Compress::Zlib) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Running transaction check
---> Package perl-IO-Compress.noarch 0:2.061-2.el7 will be installed
--> Processing Dependency: perl(Compress::Raw::Zlib) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
--> Processing Dependency: perl(Compress::Raw::Bzip2) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
---> Package perl-Net-Daemon.noarch 0:0.48-5.el7 will be installed
--> Running transaction check
---> Package perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 will be installed
---> Package perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================
 Package                                   Arch                     Version                         Repository                           Size
==============================================================================================================================================
Installing:
 mysql-community-libs                      x86_64                   5.6.38-2.el7                    mysql56-community                   2.0 M
     replacing  mariadb-libs.x86_64 1:5.5.35-3.el7
 mysql-community-server                    x86_64                   5.6.38-2.el7                    mysql56-community                    59 M
Installing for dependencies:
 mysql-community-client                    x86_64                   5.6.38-2.el7                    mysql56-community                    19 M
 mysql-community-common                    x86_64                   5.6.38-2.el7                    mysql56-community                   257 k
 perl-Compress-Raw-Bzip2                   x86_64                   2.061-3.el7                     base                                 32 k
 perl-Compress-Raw-Zlib                    x86_64                   1:2.061-4.el7                   base                                 57 k
 perl-DBI                                  x86_64                   1.627-4.el7                     base                                802 k
 perl-IO-Compress                          noarch                   2.061-2.el7                     base                                260 k
 perl-Net-Daemon                           noarch                   0.48-5.el7                      base                                 51 k
 perl-PlRPC                                noarch                   0.2020-14.el7                   base                                 36 k

Transaction Summary
==============================================================================================================================================
Install  2 Packages (+8 Dependent packages)

Total download size: 82 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.38-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Public key for mysql-community-common-5.6.38-2.el7.x86_64.rpm is not installed
(1/10): mysql-community-common-5.6.38-2.el7.x86_64.rpm                                                                 | 257 kB  00:00:32
mysql-community-libs-5.6.38-2. FAILED                                                                       ]  28 kB/s |  10 MB  00:44:43 ETA
http://repo.mysql.com/yum/mysql-5.6-community/el/7/x86_64/mysql-community-libs-5.6.38-2.el7.x86_64.rpm: [Errno 12] Timeout on http://repo.mysql.com/yum/mysql-5.6-community/el/7/x86_64/mysql-community-libs-5.6.38-2.el7.x86_64.rpm: (28, ‘Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds‘)
Trying other mirror.
(2/10): perl-DBI-1.627-4.el7.x86_64.rpm                                                                                | 802 kB  00:00:00
(3/10): perl-IO-Compress-2.061-2.el7.noarch.rpm                                                                        | 260 kB  00:00:00
(4/10): perl-Net-Daemon-0.48-5.el7.noarch.rpm                                                                          |  51 kB  00:00:00
(5/10): perl-PlRPC-0.2020-14.el7.noarch.rpm                                                                            |  36 kB  00:00:00
(6/10): perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm                                                                 |  32 kB  00:00:00
(7/10): perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm                                                                  |  57 kB  00:00:00
mysql-community-server-5.6.38- FAILED                                                                       ] 120 kB/s |  15 MB  00:09:29 ETA
http://repo.mysql.com/yum/mysql-5.6-community/el/7/x86_64/mysql-community-server-5.6.38-2.el7.x86_64.rpm: [Errno 12] Timeout on http://repo.mysql.com/yum/mysql-5.6-community/el/7/x86_64/mysql-community-server-5.6.38-2.el7.x86_64.rpm: (28, ‘Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds‘)
Trying other mirror.
(8/10): mysql-community-client-5.6.38-2.el7.x86_64.rpm                                                                 |  19 MB  00:03:31
(9/10): mysql-community-libs-5.6.38-2.el7.x86_64.rpm                                                                   | 2.0 MB  00:00:04
(10/10): mysql-community-server-5.6.38-2.el7.x86_64.rpm                                                                |  59 MB  00:09:15
----------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                         109 kB/s |  82 MB  00:12:51
Retrieving key from file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
 Userid     : "MySQL Release Engineering <[email protected]>"
 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.
  Installing : mysql-community-common-5.6.38-2.el7.x86_64                                                                                1/11
  Installing : mysql-community-libs-5.6.38-2.el7.x86_64                                                                                  2/11
  Installing : mysql-community-client-5.6.38-2.el7.x86_64                                                                                3/11
  Installing : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                                               4/11
  Installing : perl-Net-Daemon-0.48-5.el7.noarch                                                                                         5/11
  Installing : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                                                6/11
  Installing : perl-IO-Compress-2.061-2.el7.noarch                                                                                       7/11
  Installing : perl-PlRPC-0.2020-14.el7.noarch                                                                                           8/11
  Installing : perl-DBI-1.627-4.el7.x86_64                                                                                               9/11
  Installing : mysql-community-server-5.6.38-2.el7.x86_64                                                                               10/11
  Erasing    : 1:mariadb-libs-5.5.35-3.el7.x86_64                                                                                       11/11
  Verifying  : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                                                1/11
  Verifying  : perl-Net-Daemon-0.48-5.el7.noarch                                                                                         2/11
  Verifying  : perl-PlRPC-0.2020-14.el7.noarch                                                                                           3/11
  Verifying  : mysql-community-client-5.6.38-2.el7.x86_64                                                                                4/11
  Verifying  : mysql-community-server-5.6.38-2.el7.x86_64                                                                                5/11
  Verifying  : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                                               6/11
  Verifying  : mysql-community-common-5.6.38-2.el7.x86_64                                                                                7/11
  Verifying  : mysql-community-libs-5.6.38-2.el7.x86_64                                                                                  8/11
  Verifying  : perl-DBI-1.627-4.el7.x86_64                                                                                               9/11
  Verifying  : perl-IO-Compress-2.061-2.el7.noarch                                                                                      10/11
  Verifying  : 1:mariadb-libs-5.5.35-3.el7.x86_64                                                                                       11/11 

Installed:
  mysql-community-libs.x86_64 0:5.6.38-2.el7                           mysql-community-server.x86_64 0:5.6.38-2.el7                          

Dependency Installed:
  mysql-community-client.x86_64 0:5.6.38-2.el7   mysql-community-common.x86_64 0:5.6.38-2.el7   perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7
  perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7    perl-DBI.x86_64 0:1.627-4.el7                  perl-IO-Compress.noarch 0:2.061-2.el7
  perl-Net-Daemon.noarch 0:0.48-5.el7            perl-PlRPC.noarch 0:0.2020-14.el7             

Replaced:
  mariadb-libs.x86_64 1:5.5.35-3.el7                                                                                                          

Complete!
You have new mail in /var/spool/mail/root

安装成功后重启mysql服务

# service mysqld restart

初次安装mysql,root账户没有密码。

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

Copyright (c) 2000, 2017, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

mysql> 

设置密码

mysql> set password for ‘root‘@‘localhost‘=password(‘password‘);
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

配置编码格式

mysql> default-character-set =utf8
    -> 

设置允许远程连接

mysql> grant all privileges on *.* to [email protected]‘%‘identified by ‘password‘;
Query OK, 0 rows affected (0.00 sec)

mysql> 

如果允许root账号远程连接要对系统数据库的root账户设置远程访问的密码,与本地的root访问密码并不冲突。

1 grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘123456‘ with grant option; #123456为你需要设置的密码

原文地址:https://www.cnblogs.com/jpfss/p/9734229.html

时间: 2024-11-05 21:51:06

CentOS7 下的mysql安装与配置的相关文章

CentOS7下一个mysql安装

CentOS7安装MySQL --下载mysql http://mirrors.sohu.com/mysql/MySQL-5.6/ http://mirrors.sohu.com/mysql/MySQL-5.6/MySQL-5.6.24-1.linux_glibc2.5.x86_64.rpm-bundle.tar 一.准备工作 --下载后文件 MySQL-5.6.24-1.linux_glibc2.5.x86_64.rpm-bundle.tar --新建目录 mkdir /home/www/ta

linux下的mysql安装和配置

Linux下Mysql的配置 安装 rmp -ivh MySQL-server-4.1.22-0.glibc23.i386.rpm --nodeps rmp -ivh MySQL-client-4.1.22-0.glibc23.i386.rpm --nodeps 查看是否安装成功 netstat -atln 命令看到3306端口开放说明安装成功 登录 mysql [-u username] [-h host] [-p[password]] [dbname] 初始无密码,这个mysql可执行文件在

Centos7中的Mysql安装、配置和优化

1.获取Mysql的yum源 进入Mysql官网获取RPM包的下载地址:https://dev.mysql.com/downloads/repo/yum/ 2.下载和安装Mysql源 2.1.先安装wget,避免下载时未找到命令 yum -y install wget 2.2.下载mysql源安装包 [[email protected] ~]# wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm 2

CentOS7下MariaDB数据库安装及配置

前言 MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品.在存储引擎方面,使用XtraDB来代替MySQL的InnoDB. MariaDB由MySQL的创始人Michael Widenius主导开发,MariaDB名称来自Michael Widenius的女儿Maria的名字 Linux安装MariaDB 安装 使用yum安装MariaDB yum insta

CentOS7下Samba的安装与配置

一.Samba简介 Samba是在Linux和UNIX系统上实现SMB协议的一个免费软件,由服务器及客户端程序构成.SMB(Server Messages Block,信息服务块)是一种在局域网上共享文件和打印机的一种通信协议,它为局域网内的不同计算机之间提供文件及打印机等资源的共享服务.SMB协议是客户机/服务器型协议,客户机通过该协议可以访问服务器上的共享文件系统.打印机及其他资源.通过设置"NetBIOS over TCP/IP"使得Samba不但能与局域网络主机分享资源,还能与

CentOS7下zabbix3.4安装与配置

Zabbix 3.0 只支持CentOS 7.0以上版本,所以先在虚拟机中安装好CentOS 7.0 x64,并设置好IP,允许虚拟机联网. 1.关闭防火墙 设置关闭防火墙#systemctl stop firewalld.service 设置永久关闭防火墙#systemctl disable firewalld.service 2.关闭SELinux 查看SELinux状态#getenforce 修改SELinux状态#vi /etc/sysconfig/selinux/SELinux=dis

Centos7下Nginx的安装和配置

第一步: 切换到/usr/local目录,下载软件包 # cd /usr/local # wget http://nginx.org/download/nginx-1.11.5.tar.gz 第二步: 安装nginx,先执行以下命令,安装nginx依赖库,如果缺少依赖库,可能会安装失败,具体可以参考文章后面的错误提示信息. # yum install gcc-c++ # yum install pcre # yum install pcre-devel # yum install zlib # 

Centos7下Nexus3的安装和配置

参考文档:https://help.sonatype.com/repomanager3 1.要使用nexus服务需要安装jdk和maven 1.1.jdk下载地址:https://www.oracle.com/technetwork/java/javase/downloads/index.html rpm -ivh jdk-8u221-linux-x64.rpm vim /etc/profile export JAVA_HOME=/usr/java/jdk1.8.0_221-amd64 expo

CentOS7下Nginx的安装与配置

1)Nginx官网下载地址 http://nginx.org/en/download.html 2)下载在/usr/local目录并解压 cd nginx-1.16.1 3)编译并安装 yum -y install pcre-devel openssl openssl-devel ./configure --prefix=/usr/local/nginx make make install 参考:https://blog.csdn.net/hfsu0419/article/details/719