参考整合了 几篇:

1.删除mariadb和mysql
mariadb是mysql的一个分支,但要安装mysql需要删除它

执行rpm -qa|grep mariadb,查看mariadb情况,有就删除 rpm -e -nodeps mariadb....名字

查看是否已经有mysql

rpm -qa |grep mysql  有就删除

--------------------

2、安装的版本:mysql-community-common-5.6.51-2.el7.x86_64

见以下链接:

https://www.cnblogs.com/jiftle/p/6811701.html

前言:由于某些不可抗力,我要在自己的阿里云服务器上搭建hadoop+hive+mysql+tomcat环境,下为mysql的安装记录


→_→大家都知道,centos自带的repo是不会自动更新每个软件的最新版本,所以无法通过yum方式安装MySQL的高级版本。所以,即使我使劲用yum -y install mysql mysql-server mysql-devel,也是没有人会鸟我的。 
所以,正确的安装mysql5姿势是要先安装带有可用的mysql5系列社区版资源的rpm包

[root@iZ28gvqe4biZ ~]# rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
获取http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
准备中...                          ################################# [100%]
正在升级/安装...1:mysql-community-release-el7-5    ################################# [100%]

这个时候查看当前可用的mysql安装资源:

[root@iZ28gvqe4biZ ~]# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community/x86_64 MySQL Connectors Community                  17
mysql-tools-community/x86_64      MySQL Tools Community                       31
mysql56-community/x86_64          MySQL 5.6 Community Server                 199

一般来说,只要安装mysql-server跟mysql-client 
这个时候我们可以直接使用yum的方式安装MySQL了

[root@iZ28gvqe4biZ ~]# yum -y install mysql-community-server
已加载插件:langpacks
正在解决依赖关系
--> 正在检查事务
---> 软件包 mysql-community-server.x86_64.0.5.6.28-2.el7 将被 安装
--> 正在处理依赖关系 mysql-community-common(x86-64) = 5.6.28-2.el7,它被软件包 mysql-community-server-5.6.28-2.el7.x86_64 需要
--> 正在处理依赖关系 mysql-community-client(x86-64) = 5.6.28-2.el7,它被软件包 mysql-community-server-5.6.28-2.el7.x86_64 需要
--> 正在处理依赖关系 perl(DBI),它被软件包 mysql-community-server-5.6.28-2.el7.x86_64 需要
--> 正在检查事务
---> 软件包 mysql-community-client.x86_64.0.5.6.28-2.el7 将被 安装
--> 正在处理依赖关系 mysql-community-libs(x86-64) = 5.6.28-2.el7,它被软件包 mysql-community-client-5.6.28-2.el7.x86_64 需要
---> 软件包 mysql-community-common.x86_64.0.5.6.28-2.el7 将被 安装
---> 软件包 perl-DBI.x86_64.0.1.627-4.el7 将被 安装
--> 正在处理依赖关系 perl(RPC::PlServer) >= 0.2001,它被软件包 perl-DBI-1.627-4.el7.x86_64 需要
--> 正在处理依赖关系 perl(RPC::PlClient) >= 0.2000,它被软件包 perl-DBI-1.627-4.el7.x86_64 需要
--> 正在检查事务
---> 软件包 mariadb-libs.x86_64.1.5.5.40-1.el7_0 将被 取代
---> 软件包 mysql-community-libs.x86_64.0.5.6.28-2.el7 将被 舍弃
---> 软件包 perl-PlRPC.noarch.0.0.2020-14.el7 将被 安装
--> 正在处理依赖关系 perl(Net::Daemon) >= 0.13,它被软件包 perl-PlRPC-0.2020-14.el7.noarch 需要
--> 正在处理依赖关系 perl(Net::Daemon::Test),它被软件包 perl-PlRPC-0.2020-14.el7.noarch 需要
--> 正在处理依赖关系 perl(Net::Daemon::Log),它被软件包 perl-PlRPC-0.2020-14.el7.noarch 需要
--> 正在处理依赖关系 perl(Compress::Zlib),它被软件包 perl-PlRPC-0.2020-14.el7.noarch 需要
--> 正在检查事务
---> 软件包 perl-IO-Compress.noarch.0.2.061-2.el7 将被 安装
--> 正在处理依赖关系 perl(Compress::Raw::Zlib) >= 2.061,它被软件包 perl-IO-Compress-2.061-2.el7.noarch 需要
--> 正在处理依赖关系 perl(Compress::Raw::Bzip2) >= 2.061,它被软件包 perl-IO-Compress-2.061-2.el7.noarch 需要
---> 软件包 perl-Net-Daemon.noarch.0.0.48-5.el7 将被 安装
--> 正在检查事务
---> 软件包 perl-Compress-Raw-Bzip2.x86_64.0.2.061-3.el7 将被 安装
---> 软件包 perl-Compress-Raw-Zlib.x86_64.1.2.061-4.el7 将被 安装
--> 解决依赖关系完成依赖关系解决==============================================================================================Package                       架构         版本                源                       大小
==============================================================================================
正在安装:mysql-community-libs          x86_64       5.6.28-2.el7        mysql56-community       2.0 M替换  mariadb-libs.x86_64 1:5.5.40-1.el7_0mysql-community-server        x86_64       5.6.28-2.el7        mysql56-community        58 M
为依赖而安装:mysql-community-client        x86_64       5.6.28-2.el7        mysql56-community        19 Mmysql-community-common        x86_64       5.6.28-2.el7        mysql56-community       256 kperl-Compress-Raw-Bzip2       x86_64       2.061-3.el7         base                     32 kperl-Compress-Raw-Zlib        x86_64       1:2.061-4.el7       base                     57 kperl-DBI                      x86_64       1.627-4.el7         base                    802 kperl-IO-Compress              noarch       2.061-2.el7         base                    260 kperl-Net-Daemon               noarch       0.48-5.el7          base                     51 kperl-PlRPC                    noarch       0.2020-14.el7       base                     36 k事务概要
==============================================================================================
安装  2 软件包 (+8 依赖软件包)总下载量:80 M
Downloading packages:
警告:/var/cache/yum/x86_64/7/mysql56-community/packages/mysql-community-common-5.6.28-2.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
mysql-community-common-5.6.28-2.el7.x86_64.rpm 的公钥尚未安装
(1/10): mysql-community-common-5.6.28-2.el7.x86_64.rpm                 | 256 kB  00:00:14
(2/10): mysql-community-libs-5.6.28-2.el7.x86_64.rpm                   | 2.0 MB  00:02:57
(3/10): perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm                  |  57 kB  00:00:00
(4/10): perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm                 |  32 kB  00:00:00
(5/10): perl-IO-Compress-2.061-2.el7.noarch.rpm                        | 260 kB  00:00:00
(6/10): perl-Net-Daemon-0.48-5.el7.noarch.rpm                          |  51 kB  00:00:00
(7/10): perl-PlRPC-0.2020-14.el7.noarch.rpm
(8/10): perl-DBI-1.627-4.el7.x86_64.rpm                                | 802 kB  00:00:00
(9/10): mysql-community-server-5.6.28-2.el7.x86_64.rpm                 |  58 MB  00:54:45
(10/10): mysql-community-client-5.6.28-2.el7.x86_64.rpm                |  19 MB  00:20:42
总计                                                           13 kB/s |  80 MB  01:45:50
从 file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql 检索密钥
导入 GPG key 0x5072E1F5:用户ID     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"指纹       : a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5软件包     : mysql-community-release-el7-5.noarch (installed)来自       : file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。正在安装    : mysql-community-common-5.6.28-2.el7.x86_64                               1/11 正在安装    : mysql-community-libs-5.6.28-2.el7.x86_64                                 2/11 正在安装    : mysql-community-client-5.6.28-2.el7.x86_64                               3/11 正在安装    : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                              4/11 正在安装    : perl-Net-Daemon-0.48-5.el7.noarch                                        5/11 正在安装    : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                               6/11 正在安装    : perl-IO-Compress-2.061-2.el7.noarch                                      7/11 正在安装    : perl-PlRPC-0.2020-14.el7.noarch                                          8/11 正在安装    : perl-DBI-1.627-4.el7.x86_64                                              9/11 正在安装    : mysql-community-server-5.6.28-2.el7.x86_64                              10/11 正在删除    : 1:mariadb-libs-5.5.40-1.el7_0.x86_64                                    11/11 验证中      : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                               1/11 验证中      : perl-Net-Daemon-0.48-5.el7.noarch                                        2/11 验证中      : mysql-community-common-5.6.28-2.el7.x86_64                               3/11 验证中      : perl-IO-Compress-2.061-2.el7.noarch                                      4/11 验证中      : mysql-community-libs-5.6.28-2.el7.x86_64                                 5/11 验证中      : mysql-community-client-5.6.28-2.el7.x86_64                               6/11 验证中      : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                              7/11 验证中      : perl-DBI-1.627-4.el7.x86_64                                              8/11 验证中      : mysql-community-server-5.6.28-2.el7.x86_64                               9/11 验证中      : perl-PlRPC-0.2020-14.el7.noarch                                         10/11 验证中      : 1:mariadb-libs-5.5.40-1.el7_0.x86_64                                    11/11 已安装:mysql-community-libs.x86_64 0:5.6.28-2.el7   mysql-community-server.x86_64 0:5.6.28-2.el7  作为依赖被安装:mysql-community-client.x86_64 0:5.6.28-2.el7  mysql-community-common.x86_64 0:5.6.28-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            替代:mariadb-libs.x86_64 1:5.5.40-1.el7_0                                                        完毕!

安装完的配置

加入开机启动

[root@iZ28gvqe4biZ ~]# systemctl enable mysqld

启动mysql服务进程

[root@iZ28gvqe4biZ ~]# systemctl start mysqld

重置密码

[root@iZ28gvqe4biZ ~]# mysql_secure_installationNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQLSERVERS 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...

新建Hive知识库

//登录MYSQL(有ROOT权限)。这里我以ROOT身份登录
[root@iZ28gvqe4biZ ~]# mysql -u root -p
//首先为用户创建一个数据库hivemeta
mysql  > create database hivemeta;
mysql  > use hivemeta
//授权hdp用户拥有hivemeta数据库的所有权限。
mysql  > grant all privileges on *.* to hdp@"%" identified by "hdp" with grant option;
//刷新系统权限表
mysql  > flush privileges;
mysql  > use hivemeta;
//mysql/hive字符集问题
mysql  > alter database hivemeta character set latin1;

--------------------------------------------

3、以下是安装的步骤:设置密码等...

Last login: Sun Jul 25 21:29:12 2021 from 118.31.243.171

Welcome to Alibaba Cloud Elastic Compute Service !

[root@iZbp1j4bsah4nl7f6dqyu4Z ~]# ls
k
[root@iZbp1j4bsah4nl7f6dqyu4Z ~]# pwd
/root
[root@iZbp1j4bsah4nl7f6dqyu4Z ~]# rpm -qa|grep mariadb
[root@iZbp1j4bsah4nl7f6dqyu4Z ~]# uname -a
Linux iZbp1j4bsah4nl7f6dqyu4Z 3.10.0-862.14.4.el7.x86_64 #1 SMP Wed Sep 26 15:12:11 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@iZbp1j4bsah4nl7f6dqyu4Z ~]# getconf LONG_BIT
64
[root@iZbp1j4bsah4nl7f6dqyu4Z ~]# 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%]
[root@iZbp1j4bsah4nl7f6dqyu4Z ~]# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community/x86_64 MySQL Connectors Community                 212
mysql-tools-community/x86_64      MySQL Tools Community                      132
mysql56-community/x86_64          MySQL 5.6 Community Server                 581
[root@iZbp1j4bsah4nl7f6dqyu4Z ~]# 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.51-2.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.6.51-2.el7 for package: mysql-community-server-5.6.51-2.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.6.10 for package: mysql-community-server-5.6.51-2.el7.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.1)(64bit) for package: mysql-community-server-5.6.51-2.el7.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.4)(64bit) for package: mysql-community-server-5.6.51-2.el7.x86_64
--> Processing Dependency: perl(DBI) for package: mysql-community-server-5.6.51-2.el7.x86_64
--> Processing Dependency: perl(Data::Dumper) for package: mysql-community-server-5.6.51-2.el7.x86_64
--> Processing Dependency: libaio.so.1()(64bit) for package: mysql-community-server-5.6.51-2.el7.x86_64
--> Running transaction check
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
---> Package mysql-community-client.x86_64 0:5.6.51-2.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.6.10 for package: mysql-community-client-5.6.51-2.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.6.51-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
---> Package perl-Data-Dumper.x86_64 0:2.145-3.el7 will be installed
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:5.6.51-2.el7 will be installed
---> 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-server                               x86_64                              5.6.51-2.el7                                   mysql56-community                               67 M
Installing for dependencies:
 libaio                                               x86_64                              0.3.109-13.el7                                 base                                            24 k
 mysql-community-client                               x86_64                              5.6.51-2.el7                                   mysql56-community                               21 M
 mysql-community-common                               x86_64                              5.6.51-2.el7                                   mysql56-community                              287 k
 mysql-community-libs                                 x86_64                              5.6.51-2.el7                                   mysql56-community                              2.2 M
 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-Data-Dumper                                     x86_64                              2.145-3.el7                                    base                                            47 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  1 Package (+11 Dependent packages)

Total download size: 91 M
Installed size: 365 M
Downloading packages:
(1/12): 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.51-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY7 kB/s | 244 kB  00:15:57 ETA 
Public key for mysql-community-common-5.6.51-2.el7.x86_64.rpm is not installed
(2/12): mysql-community-common-5.6.51-2.el7.x86_64.rpm                                                                                                                 | 287 kB  00:00:01     
(3/12): mysql-community-libs-5.6.51-2.el7.x86_64.rpm                                                                                                                   | 2.2 MB  00:00:00     
(4/12): perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm                                                                                                                 |  32 kB  00:00:00     
(5/12): perl-DBI-1.627-4.el7.x86_64.rpm                                                                                                                                | 802 kB  00:00:00     
(6/12): perl-Data-Dumper-2.145-3.el7.x86_64.rpm                                                                                                                        |  47 kB  00:00:00     
(7/12): perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm                                                                                                                  |  57 kB  00:00:00     
(8/12): perl-IO-Compress-2.061-2.el7.noarch.rpm                                                                                                                        | 260 kB  00:00:00     
(9/12): perl-Net-Daemon-0.48-5.el7.noarch.rpm                                                                                                                          |  51 kB  00:00:00     
(10/12): perl-PlRPC-0.2020-14.el7.noarch.rpm                                                                                                                           |  36 kB  00:00:00     
(11/12): mysql-community-client-5.6.51-2.el7.x86_64.rpm                                                                                                                |  21 MB  00:00:04     
(12/12): mysql-community-server-5.6.51-2.el7.x86_64.rpm                                                                                                                |  67 MB  00:00:09     
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                         7.4 MB/s |  91 MB  00:00:12     
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.
** Found 2 pre-existing rpmdb problem(s), 'yum check' output follows:
2:postfix-2.10.1-6.el7.x86_64 has missing requires of libmysqlclient.so.18()(64bit)
2:postfix-2.10.1-6.el7.x86_64 has missing requires of libmysqlclient.so.18(libmysqlclient_18)(64bit)
  Installing : mysql-community-common-5.6.51-2.el7.x86_64                                                                                                                                1/12 
  Installing : perl-Data-Dumper-2.145-3.el7.x86_64                                                                                                                                       2/12 
  Installing : mysql-community-libs-5.6.51-2.el7.x86_64                                                                                                                                  3/12 
  Installing : mysql-community-client-5.6.51-2.el7.x86_64                                                                                                                                4/12 
  Installing : libaio-0.3.109-13.el7.x86_64                                                                                                                                              5/12 
  Installing : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                                                                                               6/12 
  Installing : perl-Net-Daemon-0.48-5.el7.noarch                                                                                                                                         7/12 
  Installing : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                                                                                                8/12 
  Installing : perl-IO-Compress-2.061-2.el7.noarch                                                                                                                                       9/12 
  Installing : perl-PlRPC-0.2020-14.el7.noarch                                                                                                                                          10/12 
  Installing : perl-DBI-1.627-4.el7.x86_64                                                                                                                                              11/12 
  Installing : mysql-community-server-5.6.51-2.el7.x86_64                                                                                                                               12/12 
  Verifying  : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                                                                                                1/12 
  Verifying  : perl-Net-Daemon-0.48-5.el7.noarch                                                                                                                                         2/12 
  Verifying  : perl-Data-Dumper-2.145-3.el7.x86_64                                                                                                                                       3/12 
  Verifying  : mysql-community-libs-5.6.51-2.el7.x86_64                                                                                                                                  4/12 
  Verifying  : perl-IO-Compress-2.061-2.el7.noarch                                                                                                                                       5/12 
  Verifying  : mysql-community-server-5.6.51-2.el7.x86_64                                                                                                                                6/12 
  Verifying  : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                                                                                               7/12 
  Verifying  : mysql-community-common-5.6.51-2.el7.x86_64                                                                                                                                8/12 
  Verifying  : perl-DBI-1.627-4.el7.x86_64                                                                                                                                               9/12 
  Verifying  : libaio-0.3.109-13.el7.x86_64                                                                                                                                             10/12 
  Verifying  : perl-PlRPC-0.2020-14.el7.noarch                                                                                                                                          11/12 
  Verifying  : mysql-community-client-5.6.51-2.el7.x86_64                                                                                                                               12/12

Installed:
  mysql-community-server.x86_64 0:5.6.51-2.el7

Dependency Installed:
  libaio.x86_64 0:0.3.109-13.el7                 mysql-community-client.x86_64 0:5.6.51-2.el7   mysql-community-common.x86_64 0:5.6.51-2.el7   mysql-community-libs.x86_64 0:5.6.51-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-Data-Dumper.x86_64 0:2.145-3.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

Complete!
[root@iZbp1j4bsah4nl7f6dqyu4Z ~]# systemctl enable mysqld
[root@iZbp1j4bsah4nl7f6dqyu4Z ~]# systemctl start mysqld
[root@iZbp1j4bsah4nl7f6dqyu4Z ~]# 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): 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Enter current password for root (enter for none): 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Enter current password for root (enter for none): 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Unable to connect to the server as root user, giving up.
Cleaning up...
[root@iZbp1j4bsah4nl7f6dqyu4Z ~]# 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): 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Enter current password for root (enter for none): 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Enter current password for root (enter for none): 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Unable to connect to the server as root user, giving up.
Cleaning up...
[root@iZbp1j4bsah4nl7f6dqyu4Z ~]# 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
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] n
 ... skipping.

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
 ... 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] n
 ... skipping.

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@iZbp1j4bsah4nl7f6dqyu4Z ~]#

---------------

show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| innodb_index_stats        |
| innodb_table_stats        |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| servers                   |
| slave_master_info         |
| slave_relay_log_info      |
| slave_worker_info         |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
28 rows in set (0.00 sec)

mysql> select host,user from user;
+-------------------------+------+
| host                    | user |
+-------------------------+------+
| 127.0.0.1               | root |
| ::1                     | root |
| izbp1j4bsah4nl7f6dqyu4z |      |
| izbp1j4bsah4nl7f6dqyu4z | root |
| localhost               |      |
| localhost               | root |
+-------------------------+------+
6 rows in set (0.00 sec)

mysql> update user set host='%' where user='root';
ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
mysql>

这样写就不出错:

将host设置为%表示任何ip都能连接mysql,当然也可指定为某个特定ip
update user set host='%' where user='root' and host='localhost';
flush privileges;        #刷新权限表,使配置生效

mysql> select host,user from user;
+-------------------------+------+
| host                    | user |
+-------------------------+------+
| 127.0.0.1               | root |
| ::1                     | root |
| izbp1j4bsah4nl7f6dqyu4z |      |
| izbp1j4bsah4nl7f6dqyu4z | root |
| localhost               |      |
| localhost               | root |
+-------------------------+------+
6 rows in set (0.00 sec)

mysql> update user set host='%' where user='root';
ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
mysql> update user set host=’%’ where user=‘root’ and host=‘localhost’;
ERROR 1054 (42S22): Unknown column '‘root’' in 'where clause'
mysql> update user set host='%' where user='root' and host='localhost';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0  Changed: 0  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

----------------4、

阿里云服务器进项设置 安全组添加 端口 数据库支持的端口3306

打开navicat

填上公网ip,端口,服务器用户名密码1

aliyun centos7.5,安装mysql5.6数据库,navicat 连接数据库相关推荐

  1. VMware虚拟机里centos7下安装mysql5.6并授权远程连接Navicat

    正文内容 这节来安装Mysql5.6,并远程授权连接本地windows的Navicat,可以根据以下步骤安装.此文章为自己收藏,必要时拿出来直接用的,有需要的友友可以查看查看的.文章图片有借助于网络的 ...

  2. Centos7下使用rpm包安装mysql5.6数据库

    Centos7下使用rpm包安装mysql5.6数据库 环境 [root@mysql01 ~]# uname -r 3.10.0-514.el7.x86_64 [root@mysql01 ~]# ca ...

  3. 数据库安装mysql57_记录CentOS7.X版本下安装MySQL5.7数据库

    记录CentOS7.X版本下安装MySQL5.7数据库 设置rpm下载目录在/opt目录下新建一个目录存放mysql cd /opt sudo mkdir mysql12 下载MySQL的源 如果在这 ...

  4. centos akonadi mysql,MySQL数据库之在CentOS7上安装MySQL5.7

    本文主要向大家介绍了MySQL数据库之在CentOS7上安装MySQL5.7 ,通过具体的内容向大家展现,希望对大家学习MySQL数据库有所帮助. 获取RPM包 # wget https://dev. ...

  5. 阿里云 centos7静默安装oracle12c,使用navicat 连接oracle数据库

    阿里云 centos7静默安装oracle12c,使用navicat 连接oracle数据库 需要切换到阿里云镜像的,仅供参考 使用yum -y update更新软件 1. 关闭防火墙 systemc ...

  6. CentOS7内网使用rpm方式安装MySQL5.6数据库

    CentOS7内网使用rpm方式安装MySQL5.6数据库 生成环境为内网环境,无法通过互联网使用Yum方式安装MySQL数据库时,可以参考本文进行安装. 系统环境 当前演示操作系统为最小化安装的Ce ...

  7. 【Tools】Centos7.5安装MySQL5.7

    00. 目录 文章目录 00. 目录 01. 学习目标 02. MySQL数据库介绍 03. Linux下MySQL安装方式 03. MySQL5.7下载 04. 卸载系统自带MySQL数据库软件 0 ...

  8. 在 CentOS7 上安装 MySQL5.7

    在 CentOS7 上安装 MySQL5.7 1 通过 SecureCRT 连接到阿里云 CentOS7 服务器: 2 进入到目录 /usr/local/ 中:  cd /usr/local/ 3 创 ...

  9. 在centOS7中装mysql_在 CentOS7 上安装 MySQL5.7

    在 CentOS7 上安装 MySQL5.7 1 通过 SecureCRT 连接到阿里云 CentOS7 服务器: 2 进入到目录 /usr/local/ 中: cd /usr/local/ 3 创建 ...

最新文章

  1. Kazoo安装和使用
  2. 只遍历出JScript对象的expando属性
  3. ZYNQ-7000如何生成从Flash和SD卡启动的镜像文件
  4. ACM OJ反馈结果大全
  5. CCNP学习笔记15-RSTP
  6. sql语句练习(二):Demand
  7. Bash的循环结构(for和while)
  8. python学习笔记(10)--组合数据类型(序列类型)
  9. 算法--递归--走台阶问题(2种递归+递归改循环)
  10. ASN.1编解码与编程
  11. 数据库——Oracle(1)
  12. java深度解析mp3文件
  13. Flutter 常见问题总结
  14. 计算机系统配置有哪些,查看电脑配置方法有哪些
  15. Opencv3.4.2调用yolov2进行物体检测源代码
  16. java applet开发_Java Applet程序开发步骤
  17. 附加:在在下部分区/县(数据表)
  18. 天大《电子商务网站设计与管理》大作业期末考核
  19. Ubuntu16.04使用ninja编译安装LLVM
  20. 哈工大计算机网络-作业讲解

热门文章

  1. OpenHD改造实现廉价高清数字图传(树莓派+PC)—(六)OSD和视频画面整合显示
  2. 【JAVA】书店管理系统(附带前后端源码及资源)
  3. 中国有哪几位Android GDE?
  4. CSS怎么控制行高?
  5. Play Framework 整合 农业银行网银
  6. 语音识别技术在米家、HomeKit和智汀等智能家居中的应用
  7. 手把手推导Ring All-reduce的数学性质
  8. 计算机发展cpu元器件,cpu由什么组成(组成cpu的元器件包括什么)
  9. Java语言 实验报告(三)
  10. Kratos Quick Start