当前位置: 首页 > news >正文

lnmp yum安装mysql_阿里云服务器上使用yum安装mysql

1 常规错误的yum安装方法:

在前文中记述了CentOS 6.5系统中通过yum方式快速地搭建了LNMP环境,那么是否也能在CentOS 7或CentOS 7.1系统中依葫芦画瓢安装MySql5.6.24呢?答案是否定的。

[root@typecodes ~]# yum -y install mysql mysql-server mysql-devel

.....................。

....省略部分安装过程....

.....................。

Installed:

mariadb.x86_64 1:5.5.41-2.el7_0 mariadb-devel.x86_64 1:5.5.41-2.el7_0

Dependency Installed:

keyutils-libs-devel.x86_64 0:1.5.8-3.el7 krb5-devel.x86_64 0:1.12.2-14.el7 libcom_err-devel.x86_64 0:1.42.9-7.el7 libselinux-devel.x86_64 0:2.2.2-6.el7

libsepol-devel.x86_64 0:2.1.9-3.el7 libverto-devel.x86_64 0:0.2.5-4.el7 openssl-devel.x86_64 1:1.0.1e-42.el7.4 pcre-devel.x86_64 0:8.32-14.el7

zlib-devel.x86_64 0:1.2.7-13.el7

Complete!

从上面的安装结果可以看出,没有安装MySQL数据库,而是安装了mariadb数据!因为在CentOS 7和CentOS 7.1系统中,默认安装的mysql是它的分支mariadb。这里引用下百度百科关于mariadb的描述:

MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。

因此,下面这些正常的MySQL操作都是无效的:

#######无法把mysql服务加入系统启动

[root@typecodes ~]# chkconfig mysqld on

error reading information on service mysqld: No such file or directory

#######启动不了mysql

[root@typecodes ~]# service mysqld start

Redirecting to /bin/systemctl start mysqld.service

Failed to issue method call: Unit mysqld.service failed to load: No such file or directory.

#######没有安装mysql相关包

[root@typecodes ~]# rpm -qa |grep mysql

php-mysql-5.4.16-23.el7_0.3.x86_64

[root@typecodes ~]#

2 正确的安装方法:

众所周知,Linux系统自带的repo是不会自动更新每个软件的最新版本(基本都是比较靠后的稳定版),所以无法通过yum方式安装MySQL的高级版本。所以我们需要先安装带有当前可用的mysql5系列社区版资源的rpm包。

#######安装rpm包

[root@typecodes ~]# 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%]

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

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

从上面的列表可以看出, mysql56-community/x86_64 和 MySQL 5.6 Community Server 可以使用。

因此,我们就可以直接用yum方式安装了MySQL5.6版本了。

[root@typecodes ~]# yum -y install mysql-community-server

Loaded plugins: axelget, langpacks

No metadata availablefor baseNo metadata availableforepel

No metadata availableforextras

(Failed to load module fastestmirror: No module named fastestmirror)

repomd.xml| 2.5 kB 00:00:00update mysql-connectors-community metadata successfully

(Failed to load module fastestmirror: No module named fastestmirror)

repomd.xml| 2.5 kB 00:00:00update mysql-tools-community metadata successfully

(Failed to load module fastestmirror: No module named fastestmirror)

repomd.xml| 2.5 kB 00:00:00update mysql56-community metadata successfully

No metadata availableforupdates

mysql-connectors-community | 2.5 kB 00:00:00mysql-tools-community | 2.5 kB 00:00:00mysql56-community | 2.5 kB 00:00:00(1/3): mysql-connectors-community/x86_64/primary_db | 7.3 kB 00:00:00(2/3): mysql56-community/x86_64/primary_db | 83 kB 00:00:01mysql-tools-community/x86_64/p FAILED ============================================== ] 19 kB/s | 92 kB 00:00:00ETA

http://repo.mysql.com/yum/mysql-tools-community/el/7/x86_64/repodata/3301d2eb425f300dec5a46c4201d08f2cf9232a6-primary.sqlite.bz2: [Errno 12] Timeout onhttp://repo.mysql.com/yum/mysql-tools-community/el/7/x86_64/repodata/3301d2eb425f300dec5a46c4201d08f2cf9232a6-primary.sqlite.bz2: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 3 seconds')

Trying other mirror.

(3/3): mysql-tools-community/x86_64/primary_db | 15 kB 00:00:00Resolving Dependencies-->Running transaction check---> Package mysql-community-server.x86_64 0:5.6.24-3.el7 will be installed--> Processing Dependency: mysql-community-common(x86-64) = 5.6.24-3.el7 for package: mysql-community-server-5.6.24-3.el7.x86_64--> Processing Dependency: mysql-community-client(x86-64) = 5.6.24-3.el7 for package: mysql-community-server-5.6.24-3.el7.x86_64--> Processing Dependency: perl(DBI) for package: mysql-community-server-5.6.24-3.el7.x86_64-->Running transaction check---> Package mariadb.x86_64 1:5.5.41-2.el7_0 will be obsoleted---> Package mysql-community-client.x86_64 0:5.6.24-3.el7 will be obsoleting--> Processing Dependency: mysql-community-libs(x86-64) = 5.6.24-3.el7 for package: mysql-community-client-5.6.24-3.el7.x86_64---> Package mysql-community-common.x86_64 0:5.6.24-3.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.41-2.el7_0 will be obsoleted--> Processing Dependency: mariadb-libs(x86-64) = 1:5.5.41-2.el7_0 for package: 1:mariadb-devel-5.5.41-2.el7_0.x86_64---> Package mysql-community-libs.x86_64 0:5.6.24-3.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 mariadb-devel.x86_64 1:5.5.41-2.el7_0 will be obsoleted---> Package mysql-community-devel.x86_64 0:5.6.24-3.el7 will be obsoleting---> 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-client x86_64 5.6.24-3.el7 mysql56-community 19M

replacing mariadb.x86_641:5.5.41-2.el7_0

mysql-community-devel x86_64 5.6.24-3.el7 mysql56-community 3.4M

replacing mariadb-devel.x86_64 1:5.5.41-2.el7_0

mysql-community-libs x86_64 5.6.24-3.el7 mysql56-community 2.0M

replacing mariadb-libs.x86_64 1:5.5.41-2.el7_0

mysql-community-server x86_64 5.6.24-3.el7 mysql56-community 58M

Installingfordependencies:

mysql-community-common x86_64 5.6.24-3.el7 mysql56-community 256k

perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 base 32k

perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 base 57k

perl-DBI x86_64 1.627-4.el7 base 802k

perl-IO-Compress noarch 2.061-2.el7 base 260k

perl-Net-Daemon noarch 0.48-5.el7 base 51k

perl-PlRPC noarch 0.2020-14.el7 base 36k

Transaction Summary=======================================================================================================================================================================Install4 Packages (+7Dependent packages)

Total download size:83M

Downloading packages:

mysql-community-devel-5.6.24-3.el7.x86_64.rpm | 3.4 MB 00:00:03mysql-community-client-5.6.24-3.el7.x86_64.rpm | 19 MB 00:00:05mysql-community-server-5.6.24-3.el7.x86_64.rpm | 58 MB 00:00:11mysql-community-libs-5.6.24-3.el7.x86_64.rpm | 2.0 MB 00:00:02perl-DBI-1.627-4.el7.x86_64.rpm | 0 B 00:00:01...

perl-DBI-1.627-4.el7.x86_64.rpm | 802 kB 00:00:00(1/6): perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm | 57 kB 00:00:00(2/6): perl-Net-Daemon-0.48-5.el7.noarch.rpm | 51 kB 00:00:00(3/6): perl-PlRPC-0.2020-14.el7.noarch.rpm | 36 kB 00:00:00(4/6): perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm | 32 kB 00:00:00(5/6): perl-IO-Compress-2.061-2.el7.noarch.rpm | 260 kB 00:00:00warning:/var/cache/yum/x86_64/7/mysql56-community/packages/mysql-community-common-5.6.24-3.el7.x86_64.rpm: V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY 00:00:01ETA

Public keyfor mysql-community-common-5.6.24-3.el7.x86_64.rpm isnot installed

(6/6): mysql-community-common-5.6.24-3.el7.x86_64.rpm | 256 kB 00:00:01

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------Total388 kB/s | 692 kB 00:00:01Retrieving keyfrom file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

Importing GPG key0x5072E1F5:

Userid :"MySQL Release Engineering "Fingerprint: a4a94068 76fc bd3c 4567 70c8 8c71 8d3b 5072e1f5

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.24-3.el7.x86_64 1/14Installing : mysql-community-libs-5.6.24-3.el7.x86_64 2/14Installing : mysql-community-client-5.6.24-3.el7.x86_64 3/14Installing : perl-Net-Daemon-0.48-5.el7.noarch 4/14Installing :1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 5/14Installing : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 6/14Installing : perl-IO-Compress-2.061-2.el7.noarch 7/14Installing : perl-PlRPC-0.2020-14.el7.noarch 8/14Installing : perl-DBI-1.627-4.el7.x86_64 9/14Installing : mysql-community-server-5.6.24-3.el7.x86_64 10/14Installing : mysql-community-devel-5.6.24-3.el7.x86_64 11/14Erasing :1:mariadb-devel-5.5.41-2.el7_0.x86_64 12/14Erasing :1:mariadb-5.5.41-2.el7_0.x86_64 13/14Erasing :1:mariadb-libs-5.5.41-2.el7_0.x86_64 14/14Verifying : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 1/14Verifying : mysql-community-common-5.6.24-3.el7.x86_64 2/14Verifying : mysql-community-devel-5.6.24-3.el7.x86_64 3/14Verifying : mysql-community-client-5.6.24-3.el7.x86_64 4/14Verifying : perl-PlRPC-0.2020-14.el7.noarch 5/14Verifying : mysql-community-server-5.6.24-3.el7.x86_64 6/14Verifying :1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 7/14Verifying : mysql-community-libs-5.6.24-3.el7.x86_64 8/14Verifying : perl-Net-Daemon-0.48-5.el7.noarch 9/14Verifying : perl-DBI-1.627-4.el7.x86_64 10/14Verifying : perl-IO-Compress-2.061-2.el7.noarch 11/14Verifying :1:mariadb-5.5.41-2.el7_0.x86_64 12/14Verifying :1:mariadb-devel-5.5.41-2.el7_0.x86_64 13/14Verifying :1:mariadb-libs-5.5.41-2.el7_0.x86_64 14/14Installed:

mysql-community-client.x86_64 0:5.6.24-3.el7 mysql-community-devel.x86_64 0:5.6.24-3.el7 mysql-community-libs.x86_64 0:5.6.24-3.el7

mysql-community-server.x86_64 0:5.6.24-3.el7

Dependency Installed:

mysql-community-common.x86_64 0:5.6.24-3.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.x86_641:5.5.41-2.el7_0 mariadb-devel.x86_64 1:5.5.41-2.el7_0 mariadb-libs.x86_64 1:5.5.41-2.el7_0

Complete!

3 MySQL安装完成后,进行相关配置

安装完MySQL后,需要进行一些基础配置工作:

#######安装成功后,将其加入开机启动

[root@typecodes~]# systemctl enable mysqld

#######启动mysql服务进程

[root@typecodes~]# systemctl start mysqld

#######配置mysql(设置密码等)

[root@typecodes~]# 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 passwordfor root (enter fornone):

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 newpassword:

Password updated successfully!Reloading privilege tables..

... Success!Bydefault, a MySQL installation has an anonymous user, allowing anyone

to log into MySQL without having to have a user account createdforthem. Thisis intended only fortesting, 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 connectfrom 'localhost'. This

ensures that someone cannot guess at the root passwordfromthe network.

Disallow root login remotely? [Y/n] y [禁止root远程登录]

... Success!Bydefault, MySQL comes with a database named 'test'that anyone can

access. Thisis also intended only fortesting, and should be removed

before moving into a production environment.

Remove test database and access to it? [Y/n] y [删除test数据库]-Dropping test database...

ERROR1008 (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.

Thanksfor using MySQL!Cleaning up...

注:此篇文章为转载而来。

相关文章:

  • 孔浩用的mysql工具_springmvc 孔浩 hibernate
  • mysql原生数据库_重温原生Mysql数据库操作
  • rpm mysql5.5_redhat安装mysql5.5(.rpm)
  • php mysql制作留言板_[PHP] PHP+MYSQL留言板制作
  • phpstom 驼峰插件_Phpstorm 插件
  • django mysql 2059_(2059,“身份验证插件'caching_sha2_password'”)在Django上运行与MYSQL数据库连接的服务器时...
  • tp5怎么生成短链接_TP5 生成二維碼
  • python中sys模块下载_python模块:sys模块
  • mysql mybatis批量删除_Mybatis批量删除和更新,中文注释插件
  • mysql启动错误1455_PL/SQL“ ORA-14551: 无法在查询中执行 DML 操作”解决
  • ubuntu安装mysql集群_Ubuntu 20.10单机安装MySQL 8.0.22 NDB集群
  • java序列化工具类_java对象序列化及反序列化SerializeUtils工具类
  • java dispatchevent_这段程序的单击事件不能执行,点击后出现如下错误:at java.awt.Component.dispatchEventImpl(Unknown Sou...
  • java kerberos配置_为kerberos配置Storm
  • java nodelist 快速排序_数据结构的实践心得(归并排序和快速排序:mergeSort、quickSort)...
  • 《Java编程思想》读书笔记-对象导论
  • 「前端早读君006」移动开发必备:那些玩转H5的小技巧
  • Android Studio:GIT提交项目到远程仓库
  • AngularJS指令开发(1)——参数详解
  • ES6, React, Redux, Webpack写的一个爬 GitHub 的网页
  • JS笔记四:作用域、变量(函数)提升
  • rabbitmq延迟消息示例
  • vue从创建到完整的饿了么(18)购物车详细信息的展示与删除
  • 分类模型——Logistics Regression
  • 前端每日实战 2018 年 7 月份项目汇总(共 29 个项目)
  • 容器服务kubernetes弹性伸缩高级用法
  • 进程与线程(三)——进程/线程间通信
  • #中国IT界的第一本漂流日记 传递IT正能量# 【分享得“IT漂友”勋章】
  • (14)目标检测_SSD训练代码基于pytorch搭建代码
  • (2)nginx 安装、启停
  • (33)STM32——485实验笔记
  • (51单片机)第五章-A/D和D/A工作原理-A/D
  • (react踩过的坑)antd 如何同时获取一个select 的value和 label值
  • (阿里巴巴 dubbo,有数据库,可执行 )dubbo zookeeper spring demo
  • (分布式缓存)Redis分片集群
  • (教学思路 C#之类三)方法参数类型(ref、out、parmas)
  • .naturalWidth 和naturalHeight属性,
  • .NET Compact Framework 3.5 支持 WCF 的子集
  • .NET CORE 2.0发布后没有 VIEWS视图页面文件
  • .NET Core 2.1路线图
  • .NET Core WebAPI中使用swagger版本控制,添加注释
  • .Net mvc总结
  • .NET 动态调用WebService + WSE + UsernameToken
  • .NET/C# 使用反射调用含 ref 或 out 参数的方法
  • @SuppressWarnings注解
  • [51nod1610]路径计数
  • [android]-如何在向服务器发送request时附加已保存的cookie数据
  • [AS3]URLLoader+URLRequest+JPGEncoder实现BitmapData图片数据保存
  • [BUUCTF]-PWN:wustctf2020_number_game解析(补码,整数漏洞)
  • [codevs1288] 埃及分数
  • [DAX] MAX函数 | MAXX函数
  • [Fri 26 Jun 2015 ~ Thu 2 Jul 2015] Deep Learning in arxiv
  • [LeetCode] 196. 删除重复的电子邮箱
  • [LOJ 6213]「美团 CodeM 决赛」radar
  • [MICROSAR Adaptive] --- autosar官方文档阅读建议