在阿里云的CentOS环境中安装配置MySQL

Welcome to Alibaba Cloud Elastic Compute Service !

[[email protected] ~]# 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%]
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community/x86_64 MySQL Connectors Community                  45
mysql-tools-community/x86_64      MySQL Tools Community                       59
mysql56-community/x86_64          MySQL 5.6 Community Server                 378
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]# 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.39-2.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.6.39-2.el7 for package: mysql-community-server-5.6.39-2.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.6.10 for package: mysql-community-server-5.6.39-2.el7.x86_64
--> Processing Dependency: perl(Data::Dumper) for package: mysql-community-server-5.6.39-2.el7.x86_64
--> Processing Dependency: perl(DBI) for package: mysql-community-server-5.6.39-2.el7.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.4)(64bit) for package: mysql-community-server-5.6.39-2.el7.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.1)(64bit) for package: mysql-community-server-5.6.39-2.el7.x86_64
--> Processing Dependency: libaio.so.1()(64bit) for package: mysql-community-server-5.6.39-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.39-2.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.6.10 for package: mysql-community-client-5.6.39-2.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.6.39-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 mariadb-libs.x86_64 1:5.5.56-2.el7 will be obsoleted
---> Package mysql-community-libs.x86_64 0:5.6.39-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.39-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.39-2.el7                                            mysql56-community                                           59 M
Installing for dependencies:
 libaio                                                           x86_64                                          0.3.109-13.el7                                          base                                                        24 k
 mysql-community-client                                           x86_64                                          5.6.39-2.el7                                            mysql56-community                                           19 M
 mysql-community-common                                           x86_64                                          5.6.39-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-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  2 Packages (+10 Dependent packages)

Total download size: 82 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.39-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Public key for mysql-community-common-5.6.39-2.el7.x86_64.rpm is not installed
(2/12): mysql-community-common-5.6.39-2.el7.x86_64.rpm                                                                                                                                                              | 257 kB  00:00:00
(3/12): mysql-community-libs-5.6.39-2.el7.x86_64.rpm                                                                                                                                                                | 2.0 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-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm                                                                                                                                                               |  57 kB  00:00:00
(7/12): perl-Data-Dumper-2.145-3.el7.x86_64.rpm                                                                                                                                                                     |  47 kB  00:00:00
(8/12): perl-Net-Daemon-0.48-5.el7.noarch.rpm                                                                                                                                                                       |  51 kB  00:00:00
(9/12): perl-PlRPC-0.2020-14.el7.noarch.rpm                                                                                                                                                                         |  36 kB  00:00:00
(10/12): perl-IO-Compress-2.061-2.el7.noarch.rpm                                                                                                                                                                    | 260 kB  00:00:00
(11/12): mysql-community-client-5.6.39-2.el7.x86_64.rpm                                                                                                                                                             |  19 MB  00:00:03
(12/12): mysql-community-server-5.6.39-2.el7.x86_64.rpm                                                                                                                                                             |  59 MB  00:00:07
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                      9.2 MB/s |  82 MB  00:00:08
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
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : perl-Data-Dumper-2.145-3.el7.x86_64                                                                                                                                                                                    1/13
  Installing : mysql-community-common-5.6.39-2.el7.x86_64                                                                                                                                                                             2/13
  Installing : mysql-community-libs-5.6.39-2.el7.x86_64                                                                                                                                                                               3/13
  Installing : mysql-community-client-5.6.39-2.el7.x86_64                                                                                                                                                                             4/13
  Installing : libaio-0.3.109-13.el7.x86_64                                                                                                                                                                                           5/13
  Installing : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                                                                                                                                            6/13
  Installing : perl-Net-Daemon-0.48-5.el7.noarch                                                                                                                                                                                      7/13
  Installing : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                                                                                                                                             8/13
  Installing : perl-IO-Compress-2.061-2.el7.noarch                                                                                                                                                                                    9/13
  Installing : perl-PlRPC-0.2020-14.el7.noarch                                                                                                                                                                                       10/13
  Installing : perl-DBI-1.627-4.el7.x86_64                                                                                                                                                                                           11/13
  Installing : mysql-community-server-5.6.39-2.el7.x86_64                                                                                                                                                                            12/13
  Erasing    : 1:mariadb-libs-5.5.56-2.el7.x86_64                                                                                                                                                                                    13/13
  Verifying  : mysql-community-server-5.6.39-2.el7.x86_64                                                                                                                                                                             1/13
  Verifying  : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                                                                                                                                             2/13
  Verifying  : perl-Net-Daemon-0.48-5.el7.noarch                                                                                                                                                                                      3/13
  Verifying  : mysql-community-common-5.6.39-2.el7.x86_64                                                                                                                                                                             4/13
  Verifying  : perl-Data-Dumper-2.145-3.el7.x86_64                                                                                                                                                                                    5/13
  Verifying  : mysql-community-libs-5.6.39-2.el7.x86_64                                                                                                                                                                               6/13
  Verifying  : perl-PlRPC-0.2020-14.el7.noarch                                                                                                                                                                                        7/13
  Verifying  : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                                                                                                                                            8/13
  Verifying  : perl-DBI-1.627-4.el7.x86_64                                                                                                                                                                                            9/13
  Verifying  : libaio-0.3.109-13.el7.x86_64                                                                                                                                                                                          10/13
  Verifying  : mysql-community-client-5.6.39-2.el7.x86_64                                                                                                                                                                            11/13
  Verifying  : perl-IO-Compress-2.061-2.el7.noarch                                                                                                                                                                                   12/13
  Verifying  : 1:mariadb-libs-5.5.56-2.el7.x86_64                                                                                                                                                                                    13/13 

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

Dependency Installed:
  libaio.x86_64 0:0.3.109-13.el7     mysql-community-client.x86_64 0:5.6.39-2.el7     mysql-community-common.x86_64 0:5.6.39-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              

Replaced:
  mariadb-libs.x86_64 1:5.5.56-2.el7                                                                                                                                                                                                       

Complete!
[[email protected] ~]#
[[email protected] ~]# systemctl enable mysqld
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]# systemctl start mysqld
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]# 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] 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] Y
 ... Success!

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...
[[email protected] ~]# 
[[email protected] ~]#
[[email protected] ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.6.39 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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 tables;
ERROR 1046 (3D000): No database selected
mysql> show dababases;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘dababases‘ at line 1
mysql>
mysql> 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>
mysql>
mysql> 

https://yq.aliyun.com/ziliao/132362

https://www.cnblogs.com/thinkingandworkinghard/p/6711255.html

原文地址:https://www.cnblogs.com/softidea/p/8683755.html

时间: 2024-10-10 05:57:10

在阿里云的CentOS环境中安装配置MySQL的相关文章

在阿里云的CentOS环境中安装django

购买了一台阿里云主机.操作系统为CentOS 6.5.准备在上面跑Django做Web开发.因为CentOS自带的python版本号较低,安装Django先要安装新版本号python.还是费了点周折. 1,升级Python 阿里云给配置好的centos 6.5下的默认Python版本号是2.6,跟Django的最新版本号须要的Python环境是不配套的.在django的安装文档里有: Being a Python Web framework, Django requires Python. It

如何在CentOS系统中安装配置SNMP服务

CentOS(Community Enterprise Operating System,中文意思是:社区企业操作系统)是Linux发行版之一,现在有一大部分服务器在使用此操作系统:SNMP(简单网络管理协议)能够使网络管理员提高网络管理效能,及时发现并解决网络问题以及规划网络的增长.网络管理员还可以通过SNMP接收网络节点的通知消息以及告警事件报告等来获知网络出现的问题.本文主要介绍如何在CentOS系统中安装配置SNMP服务. 工具/原料 CentOS操作系统 方法/步骤 使用SNMP服务前

在CentOS 6 中安装 Apache,Mysql, PHP

1.安装Apache 在终端中输入下面的命令就可以安装Apache了: sudo yum install httpd sudo的意思是用root用户做什么操作.要点击y就确认下载安装了,非常方便. 然后用下面的命令来启动服务 sudo service httpd start 现在不用着急往下弄,直接在浏览器中输入DigitalOcean给你的IP地址,应该就可以访问到Apache的欢迎页面了.类似下面的样子: 是不是很酷?如果你的域名已经成功解析到你主机的IP地址上的话,用你的域名应该也可以访问

阿里云上Oracle 11g RAC安装配置手册

有印象的用户可能发现,阿里云早在2016年深圳云栖大会就官方发布了对Oracle RAC的支持,但是相关产品却一直没能同步推出,相信大家都翘首以盼了许久许久.一个好消息是,近期阿里云将紧密推出两款新产品:共享块存储和ECS多网卡.这两款产品将打通众多关键云下应用上云的最后一公里,为用户提供更多的便利.在我们能正式体验到新产品之前,阿里云技术服务团队也将云上的Oracle RAC安装配置手册放出,希望能给大家提供更多不同的体验和选择. 一.安装说明 阿里云上Oracle RAC的安装部署,重点需要

阿里云服务器centos 6.5 jdk tomcat mysql vsftp配置 及 tomcat自启动

工具:putty (默认vim编辑xml有高亮文本,推荐)或者SecureCRT 1.vsftp a.使用yum命令, yum install vsftpd –y b.用cd和ls命令检查下nologin的位置,一般在/sbin/nologin或/usr/sbin/nologin c.使用 useradd -d /web -s /sbin/nologin ftpadmin命令增加账户,其中/web 为你的ftp目录,ftpadmin为你的ftp用户名. d.使用vi命令编辑ftp的配置文件,将配

阿里云入坑指南&amp;&amp;nodejs 安装配置

买了阿里云1G1核1M的机器(800元,3年) 登录阿里云-实例-选择实例所在地区-重置密码 用公网IP ssh连接 nodejs 安装配置 #更新阿里云版本yum -y update cd /usr/local/src , 这个文件夹通常用来存放软件源代码 #wget命令下载Node.js安装包.wget是一个从网络上自动下载文件的自由工具.它支持HTTP,HTTPS和FTP协议,可以使用HTTP代理. wget http://nodejs.org/dist/v0.12.5/node-v0.1

CentOS 6.5系统中安装配置MySQL数据库

就像Windows server 2003,2008中一般安装的是Sql Server 数据库,在linux系统中一般安装的是mysql数据库,而且Mysql数据库的第一个版本就是发行在Linux系统上的. 一.mysql简介 MySQL是一个关系型数据库管理系统,由瑞典MySQL AB公司开发,目前属于Oracle公司.MySQL是一种关联数据库管理系统,关联数据库将数据保存在不同的表中,而不是将所有数据放在一个大仓库内,这样就增加了速度并提高了灵活性.MySQL的SQL语言是用于访问数据库的

CentOS 7.2 安装配置mysql主从服务器

MySQL官方压缩包安装: 1:下载mysql官方版本,此处以目前最新版本5.7.14为例,下载的64位版本文件为: mysql-5.7.14-linux-glibc2.5-x86_64.tar 2:解压文件 mv mysql-5.7.14-linux-glibc2.5-x86_64.tar /opt/mysql-5.7.14-linux-glibc2.5-x86_64.tar tar -zvxf mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz mv mysq

Centos 6.5 安装配置Mysql MHA

MHA是什么?MHA是由日本Mysql专家用Perl写的一套Mysql故障切换方案,来保障数据库的高可用性,它的功能是能在0-30s之内实现主Mysql故障转移(failover),MHA故障转移可以很好的帮我们解决从库数据的一致性问题,同时最大化挽回故障发生后数据的一致性.MHA里有两个角色一个是node节点 一个是manager节点,要实现这个MHA,必须最少要三台数据库服务器,一主多备,即一台充当master,一台充当master的备份机,另外一台是从属机,这里实验为了实现更好的效果使用四