好像在CentOS 7系统中,默认安装的mysql是它的分支mariadb。所以不能像CentOS-6.3那样安装,如下:

[root@izwz ~]# yum -y install mysql mysql-server mysql-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Package 1:mariadb-5.5.56-2.el7.x86_64 already installed and latest version
No package mysql-server available.
Package 1:mariadb-devel-5.5.56-2.el7.x86_64 already installed and latest version
Nothing to do

所以按如下步骤安装:

1.下载rpm包

[root@izwz ~]# rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
Retrieving http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-release-el7-5 ################################# [100%]

2.查看当前可用的mysql安装资源

[root@izwz ~]# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community/x86_64 MySQL Connectors Community 42
mysql-tools-community/x86_64 MySQL Tools Community 51
mysql56-community/x86_64 MySQL 5.6 Community Server 361

3.yum安装

[root@izwz ~]# yum -y install mysql-community-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
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: libaio.so.1(LIBAIO_0.4)(64bit) for package: mysql-community-server-5.6.38-2.el7.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.1)(64bit) for package: mysql-community-server-5.6.38-2.el7.x86_64
--> Processing Dependency: libaio.so.1()(64bit) for package: mysql-community-server-5.6.38-2.el7.x86_64
--> Running transaction check
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
---> Package mariadb.x86_64 1:5.5.56-2.el7 will be obsoleted
---> Package mysql-community-client.x86_64 0:5.6.38-2.el7 will be obsoleting
--> 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
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.56-2.el7 will be obsoleted
--> Processing Dependency: mariadb-libs(x86-64) = 1:5.5.56-2.el7 for package: 1:mariadb-devel-5.5.56-2.el7.x86_64
---> Package mysql-community-libs.x86_64 0:5.6.38-2.el7 will be obsoleting
--> Running transaction check
---> Package mariadb-devel.x86_64 1:5.5.56-2.el7 will be obsoleted
---> Package mysql-community-devel.x86_64 0:5.6.38-2.el7 will be obsoleting
--> Finished Dependency Resolution Dependencies Resolved =======================================================================================================
Package Arch Version Repository Size
=======================================================================================================
Installing:
mysql-community-client x86_64 5.6.38-2.el7 mysql56-community 19 M
replacing mariadb.x86_64 1:5.5.56-2.el7
mysql-community-devel x86_64 5.6.38-2.el7 mysql56-community 3.4 M
replacing mariadb-devel.x86_64 1:5.5.56-2.el7
mysql-community-libs x86_64 5.6.38-2.el7 mysql56-community 2.0 M
replacing mariadb-libs.x86_64 1:5.5.56-2.el7
mysql-community-server x86_64 5.6.38-2.el7 mysql56-community 59 M
Installing for dependencies:
libaio x86_64 0.3.109-13.el7 base 24 k
mysql-community-common x86_64 5.6.38-2.el7 mysql56-community 257 k Transaction Summary
=======================================================================================================
Install 4 Packages (+2 Dependent packages) Total download size: 84 M
Downloading packages:
(1/6): libaio-0.3.109-13.el7.x86_64.rpm | 24 kB 00:00:00
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
(2/6): mysql-community-common-5.6.38-2.el7.x86_64.rpm | 257 kB 00:00:00
(3/6): mysql-community-devel-5.6.38-2.el7.x86_64.rpm | 3.4 MB 00:00:00
(4/6): mysql-community-libs-5.6.38-2.el7.x86_64.rpm | 2.0 MB 00:00:00
(5/6): mysql-community-client-5.6.38-2.el7.x86_64.rpm | 19 MB 00:00:02
(6/6): mysql-community-server-5.6.38-2.el7.x86_64.rpm | 59 MB 00:00:05
-------------------------------------------------------------------------------------------------------
Total 12 MB/s | 84 MB 00:00:07
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
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/9
Installing : mysql-community-libs-5.6.38-2.el7.x86_64 2/9
Installing : mysql-community-client-5.6.38-2.el7.x86_64 3/9
Installing : libaio-0.3.109-13.el7.x86_64 4/9
Installing : mysql-community-server-5.6.38-2.el7.x86_64 5/9
Installing : mysql-community-devel-5.6.38-2.el7.x86_64 6/9
Erasing : 1:mariadb-devel-5.5.56-2.el7.x86_64 7/9
Erasing : 1:mariadb-5.5.56-2.el7.x86_64 8/9
Erasing : 1:mariadb-libs-5.5.56-2.el7.x86_64 9/9
Verifying : mysql-community-libs-5.6.38-2.el7.x86_64 1/9
Verifying : mysql-community-client-5.6.38-2.el7.x86_64 2/9
Verifying : mysql-community-devel-5.6.38-2.el7.x86_64 3/9
Verifying : mysql-community-server-5.6.38-2.el7.x86_64 4/9
Verifying : mysql-community-common-5.6.38-2.el7.x86_64 5/9
Verifying : libaio-0.3.109-13.el7.x86_64 6/9
Verifying : 1:mariadb-devel-5.5.56-2.el7.x86_64 7/9
Verifying : 1:mariadb-libs-5.5.56-2.el7.x86_64 8/9
Verifying : 1:mariadb-5.5.56-2.el7.x86_64 9/9 Installed:
mysql-community-client.x86_64 0:5.6.38-2.el7 mysql-community-devel.x86_64 0:5.6.38-2.el7
mysql-community-libs.x86_64 0:5.6.38-2.el7 mysql-community-server.x86_64 0:5.6.38-2.el7 Dependency Installed:
libaio.x86_64 0:0.3.109-13.el7 mysql-community-common.x86_64 0:5.6.38-2.el7 Replaced:
mariadb.x86_64 1:5.5.56-2.el7 mariadb-devel.x86_64 1:5.5.56-2.el7 mariadb-libs.x86_64 1:5.5.56-2.el7 Complete!

安装完成。

4.启动MySQL

[root@izwz ~]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service

5.查看运行状态

[root@izwz ~]# service mysqld status
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Community Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2017-11-02 18:53:14 CST; 11min ago
Main PID: 13242 (mysqld_safe)
CGroup: /system.slice/mysqld.service
├─13242 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─13409 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mysqld.log --pid-file=/var/run/mys... Nov 02 18:53:12 izwz9f55c9f7l08ddn5qz7z mysql-systemd-start[13183]: which will also give you the option of removing the test
Nov 02 18:53:12 izwz9f55c9f7l08ddn5qz7z mysql-systemd-start[13183]: databases and anonymous user created by default. This is
Nov 02 18:53:12 izwz9f55c9f7l08ddn5qz7z mysql-systemd-start[13183]: strongly recommended for production servers.
Nov 02 18:53:13 izwz9f55c9f7l08ddn5qz7z mysql-systemd-start[13183]: See the manual for more instructions.
Nov 02 18:53:13 izwz9f55c9f7l08ddn5qz7z mysql-systemd-start[13183]: Please report any problems at http://bugs.mysql.com/
Nov 02 18:53:13 izwz9f55c9f7l08ddn5qz7z mysql-systemd-start[13183]: The latest information about MySQL is available on the web at
Nov 02 18:53:13 izwz9f55c9f7l08ddn5qz7z mysql-systemd-start[13183]: http://www.mysql.com
Nov 02 18:53:13 izwz9f55c9f7l08ddn5qz7z mysqld_safe[13242]: 171102 18:53:13 mysqld_safe Logging to '/var/log/mysqld.log'.
Nov 02 18:53:13 izwz9f55c9f7l08ddn5qz7z mysqld_safe[13242]: 171102 18:53:13 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Nov 02 18:53:14 izwz9f55c9f7l08ddn5qz7z systemd[1]: Started MySQL Community Server.

到这应该没有问题了,接下来就是怎么配置的问题了。


配置mysql,设置密码等

#配置mysql

[root@izwz ~]# 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 1008 (HY000) at line 1: 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...
[root@izwz ~]#

第一次项目上Linux服务器(五:CentOS7下Mysql数据库的安装与配置(转))的更多相关文章

  1. Linux学习之CentOS6下Mysql数据库的安装与配置

    转自:http://www.cnblogs.com/xiaoluo501395377/archive/2013/04/07/3003278.html 如果要在Linux上做j2ee开发,首先得搭建好j ...

  2. Linux学习之CentOS--CentOS6.下Mysql数据库的安装与配置

    跟着配置,顺利配置完成 http://www.cnblogs.com/xiaoluo501395377/archive/2013/04/07/3003278.html

  3. 第一次项目上Linux服务器(四:CentOS6下Mysql数据库的安装与配置(转))

    一.mysql简介 说到数据库,我们大多想到的是关系型数据库,比如mysql.oracle.sqlserver等等,这些数据库软件在windows上安装都非常的方便,在Linux上如果要安装数据库,咱 ...

  4. [转] Linux学习之CentOS(十三)--CentOS6.4下Mysql数据库的安装与配置

    from:  http://www.cnblogs.com/xiaoluo501395377/archive/2013/04/07/3003278.html 如果要在Linux上做j2ee开发,首先得 ...

  5. Linux学习之CentOS--CentOS6.4下Mysql数据库的安装与配置【转】

      如果要在Linux上做j2ee开发,首先得搭建好j2ee的开发环境,包括了jdk.tomcat.eclipse的安装(这个在之前的一篇随笔中已经有详细讲解了Linux学习之CentOS(七)--C ...

  6. Linux学习之CentOS(十三)--CentOS6.4下Mysql数据库的安装与配置

    原文:http://www.cnblogs.com/xiaoluo501395377/archive/2013/04/07/3003278.html 如果要在Linux上做j2ee开发,首先得搭建好j ...

  7. Linux学习之CentOS(十三)--CentOS6.4下Mysql数据库的安装与配置(转)

    原文地址:http://www.cnblogs.com/xiaoluo501395377/archive/2013/04/07/3003278.html 如果要在Linux上做j2ee开发,首先得搭建 ...

  8. Linux CentOS6.4下Mysql数据库的安装与配置

    一.mysql简介 说到数据库,我们大多想到的是关系型数据库,比如mysql.oracle.sqlserver等等,这些数据库软件在windows上安装都非常的方便,在Linux上如果要安装数据库,咱 ...

  9. Linux学习之CentOS(一)--CentOS6.6下Mysql数据库的安装与配置

    在这里我是通过yum来进行mysql数据库的安装的,通过这种方式进行安装,可以将跟mysql相关的一些服务.jar包都给我们安装好,所以省去了很多不必要的麻烦!!! [root@larry ~]# c ...

随机推荐

  1. POJ3046选蚂蚁创建集合_线性DP

    POJ3046选蚂蚁创建集合 一个人的精力是有限的呢,如果一直做一件事迟早会疲惫,所以自己要把握好,不要一直埋头于一件事,否则效率低下还浪费时间 题目大意:一共有T(1,2...n为其种类)种蚂蚁,A ...

  2. AngularJS 事件广播与接收 $broadcast,$emit,$on 作用域间通信 封装factory服务 发布订阅

    不同作用域之间通过组合使用$broadcast,$emit,$on的事件广播机制来进行通信. 一.说明 1.广播 $broadcast 说明:将事件从父级作用域传播至本作用域及子级作用域. 格式:$b ...

  3. 关于使用java自动发邮件--找不到smtphost

    今天解决报的第二个异常:Unknown SMTP host: smtp.qq.com;在找了网上的一些资料后,有看到是因为使用了代理服务器,所以无法访问.我试着用了telnet去访问,确实不行.最近都 ...

  4. LDAP常用属性及其描述

    属性 全名 描述 dn distinguished name 唯一标识名,类似于绝对路径,每个对象都有唯一标识名. 例如:uid=tester,ou=People,dc=example,dc=com ...

  5. CentOS 7配置Let’s Encrypt支持免费泛域名证书

    Let’s Encrypt从2018年开始支持泛域名证书,有效期3个月,目前仅支持acme方式申请,暂不支持certbot. 1.安装acme.sh curl https://get.acme.sh ...

  6. NHibernate问题求大神解决!!!

    这是我定义的实体类 对应的数据库表 映射文件 数据访问层写的是插入语句 错误: 捕捉到 NHibernate.Exceptions.GenericADOException HResult=-21462 ...

  7. MVC 视图不使用模板页的两种方法

    直接对view页面的Layout值设置null @{ Layout = null;//"~/Views/Shared/_Layout.cshtml"; } 对_ViewStart. ...

  8. 使用Charles对Android App的https请求进行抓包

    本文背景 公司新项目要求抓取目前市面上一些热门App的数据,经过研究发现很多App的网络请求都使用https进行数据传输,这样问题就来了,http使用明文传输所有请求都能拦截到,而https请求无法拦 ...

  9. sam(后缀自动机)

    后缀自动机ins解释 void ins(int c){ int p=last;//将当前节点的parent节点变为last int np=++cnt;//建立新节点 last=np;//将last设为 ...

  10. tcp server

    SO_REUSEADDR Ignore SIGPIPE TCP_NODELAY TCP_QUICKACK