在Hadoop开发的时候我们要用到mysql数据库,因此我们有必要学习一下怎样在Linux下安装mysql。

第一步:下载MySQL-client-5.1.73-1.glibc23.x86_64.rpm和MySQL-server-5.1.73-1.glibc23.x86_64.rpm

我们在地址栏输入:http://ftp.ntu.edu.tw/pub/MySQL/Downloads/MySQL-5.1/回车就会看到如下图所示界面,我们找到我们要下载的文件进行下载。

第二步:将上面下载的两个文件上传到服务器,这里我用的是CentOS虚拟机,我们可以使用FileZilla工具将文件上传上去。如下图所示。

第三步:先安装MySQL-server-5.1.73-1.glibc23.x86_64.rpm

[root@itcast05 ~]# ls

anaconda-ks.cfg                Desktop    hadoop-2.2.0         install.log.syslog    MySQL-client-5.1.73-1.glibc23.x86_64.rpm  protobuf-2.5.0.tar.gz  Templates

apache-ant-1.9.2-bin.tar.gz    Documents  hadoop-2.2.0.tar.gz  jdk-7u80-linux-x64.gz MySQL-server-5.1.73-1.glibc23.x86_64.rpm  Public                 Videos

apache-maven-3.0.5-bin.tar.gz  Downloads  install.log          Music                  Pictures                                  target

我们使用命令rpm -ivh MySQL-server-5.1.73-1.glibc23.x86_64.rpm来进行安装,其中i是安装的意思,v是显示详情的意思,h是显示进度条的意思。我们会发现与本地已经安装的mysql数据库发生了冲突。

[root@itcast05 ~]# rpm -ivh MySQL-server-5.1.73-1.glibc23.x86_64.rpm

Preparing...                ########################################### [100%]

file /usr/share/mysql/charsets/README from install of MySQL-server-5.1.73-1.glibc23.x86_64 conflicts with file from package mysql-libs-5.1.73-7.el6.x86_64

file /usr/share/mysql/charsets/Index.xml from install of MySQL-server-5.1.73-1.glibc23.x86_64 conflicts with file from package mysql-libs-5.1.73-7.el6.x86_64

file /usr/share/mysql/charsets/armscii8.xml from install of MySQL-server-5.1.73-1.glibc23.x86_64 conflicts with file from package mysql-libs-5.1.73-7.el6.x86_64

file /usr/share/mysql/charsets/ascii.xml from install of MySQL-server-5.1.73-1.glibc23.x86_64 conflicts with file from package mysql-libs-5.1.73-7.el6.x86_64

省略了一部分信息

[root@itcast05 ~]#

既然发生了冲突,我们便来解决这个问题,我们先找到本地已有的mysql,我们使用命令rpm -qa | grep mysql可以找到本地的mysql。

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

mysql-libs-5.1.73-7.el6.x86_64

找到mysql-libs-5.1.73-7.el6.x86_64之后我们来卸载它,使用的命令是rpm -e mysql-libs-5.1.73-7.el6.x86_64,我们会发现报错了,说有依赖项。

[root@itcast05 ~]# rpm -e mysql-libs-5.1.73-7.el6.x86_64

error: Failed dependencies:

libmysqlclient.so.16()(64bit) is needed by (installed) postfix-2:2.6.6-6.el6_7.1.x86_64

libmysqlclient.so.16(libmysqlclient_16)(64bit) is needed by (installed) postfix-2:2.6.6-6.el6_7.1.x86_64

mysql-libs is needed by (installed) postfix-2:2.6.6-6.el6_7.1.x86_64

那么我们就使用强制卸载的方式来卸载,方法是在命令后加--nodeps,意思是强制解除依赖关系。

[root@itcast05 ~]# rpm -e mysql-libs-5.1.73-7.el6.x86_64 --nodeps

[root@itcast05 ~]#

卸载完了原来的mysql,我们现在再来安装server,如下所示,发现安装成功了。

[root@itcast05 ~]#

rpm -ivh MySQL-server-5.1.73-1.glibc23.x86_64.rpm

Preparing...                ########################################### [100%]

1:MySQL-server           ########################################### [100%]

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !

To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'

/usr/bin/mysqladmin -u root -h itcast05 password 'new-password'

Alternatively you can run:

/usr/bin/mysql_secure_installation

which will also give you the option of removing the test

databases and anonymous user created by default.  This is

strongly recommended for production servers.

See the manual for more instructions.

Please report any problems with the /usr/bin/mysqlbug script!

Starting MySQL. SUCCESS!

[root@itcast05 ~]#

第四步:安装MySQL-client-5.1.73-1.glibc23.x86_64.rpm

我们为了配置方便,再安装一下client,如下所示

[root@itcast05 ~]#

rpm -ivh MySQL-client-5.1.73-1.glibc23.x86_64.rpm

Preparing...                ########################################### [100%]

1:MySQL-client           ########################################### [100%]

[root@itcast05 ~]#

第五步:初始化Mysql

由于我们现在还不知道mysql的用户名和密码,因此我们需要对mysql进行初始化,那么怎么初始化呢?其实我们安装

MySQL-server-5.1.73-1.glibc23.x86_64.rpm的时候人家已经告诉我们了,在安装的信息当中有这么一段话,意思是我们可以使用

/usr/bin/mysql_secure_installation这条命令来进行初始化。

Alternatively you can run:

/usr/bin/mysql_secure_installation

那我们便使用/usr/bin/mysql_secure_installation这个脚本来初始化一下

[root@itcast05 ~]#

/usr/bin/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.

接下来会让我们选择是否现在设置密码,我们选择"Y"

Set root password? [Y/n] Y

这里输入密码,比如我们就用root作为密码

New password:

再次输入密码,我们再次输入root

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.

提示是否删除所有匿名用户,我们选择"Y"进行删除。

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.

提示是否不允许远程连接,我们选择"n"意思是允许远程连接

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.

提示是否删除测试数据库,我们不删除,选择n

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.

提示是否重新刷新表权限,我们选择"Y"

Reload privilege tables now? [Y/n] Y

... Success!

Cleaning up...

到此我们的mysql初始化便完成了。

All done!  If you've completed all of the above steps, your MySQL

installation should now be secure.

Thanks for using MySQL!

[root@itcast05 ~]#

第六步:检验安装成果

我们登录mysql,我们使用我们刚才设置的root密码来登录,发现登录成功了!

[root@itcast05 ~]#

mysql -uroot -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 6

Server version: 5.1.73 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, 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>

我们来查看一下当前都有哪些数据库,发现正确查到了结果,说明我们的mysql安装成功了!!

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| test               |

+--------------------+

3 rows in set (0.00 sec)

mysql>

64位linux安装mysql数据库吗_Linux下安装Mysql数据库相关推荐

  1. linux mysql 指令无效_linux下安装mysql,mysql命令失效的原因

    一 安装步骤 从这里下载你需要的版本(注意选择你操作系统是64位的还是32位的):   下载地址 这里只介绍两种判断linux是64位还是32的方法: 命令:file /bin/cat [root@a ...

  2. Linux里下载mysql显示红色_Linux下安装mysql

    到mysql官网下载mysql编译好的二进制安装包,在下载页面Select Platform:选项选择linux-generic,然后把页面拉到底部,64位系统下载Linux - Generic (g ...

  3. linux mysql 匿名用户_Linux下安装mysql

    linux版本:CentOS7 64位 1.下载安装包"mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz # 安装依赖 yum -y install per ...

  4. linux下安装mysql的方式_linux下安装mysql的两种方式

    linux下安装mysql的两种方式 1 源码安装 1 创建mysql用户: useradd mysql passwd mysql 2 解压缩下载的mysql包: tar -zxvf mysql-5. ...

  5. linux的mysql主主_Linux下指定mysql数据库数据配置主主同步的实例

    一. 概念:① 数据库同步  (主从同步 --- 主数据库写的同时 往从服务器写数据) ② 数据库同步  (主主同步 --- 两台数据库服务器互相写数据) 二. 举例 主主数据库同步服务器配置 数据库 ...

  6. 卸载linux下的mysql数据库实例_Linux下卸载MySQL数据库实例教程

    本文主要介绍了Linux下卸载MySQL数据库的方法,不知道Linux下卸载MySQL数据库的小伙伴们可以学习一下,本文具有一定的参考价值,希望能帮助到大家. 如何在Linux下卸载MySQL数据库呢 ...

  7. linux怎么配置mysql数据库服务器_linux下指定mysql数据库服务器主从同步的配置实例...

    一. 概念:① 数据库同步  (主从同步 --- 主数据库写的同时 往从服务器写数据) ② 数据库同步  (主主同步 --- 两台数据库服务器互相写数据) 二. 举例数据库服务器(A) 主数据库   ...

  8. linux mysql怎么启动_linux下安装完mysql 怎么启动

    匿名用户 1级 2017-10-17 回答 查找以前是否安装有mysql,使用下面命令: rpm -qa|grep -i mysql 如果显示有如下包则说明已安装mysql mysql-4.1.12- ...

  9. 在linux中连接mysql数据库服务器_Linux下连接Mysql服务器的方式

    一:mysql连接简介 1.linux下mysql的连接方式有三种: 本地mysql命令连接 客户端命令连接 脚本语言封装方法连接 2.linux下mysql的连接方法有两种: TCP/IP协议连接 ...

最新文章

  1. 看!那全球最伟大的人工智能女性科学家们!
  2. Verilog以及VHDL所倡导的的代码准则
  3. dos与ddos攻击原理
  4. 《Effective-Ruby》读书笔记
  5. 在C#2.0中使用Nullable可空类型(转帖)
  6. 百度推送管理插件3.4.9Pro
  7. jmeter测试之参数化---以测试多个用户登录为例。
  8. IEEE发布AI三原则:机器人革命中需要保护人类福祉 | 138页报告
  9. IDEACould not autowire. No beans of 'xxxMapper' type found.
  10. Apache的下载安装(主要说的 64位)及问题
  11. java中json数组如何转为对象
  12. android之框架xUtils介绍
  13. 流利阅读 2019.2.27 How sky-high rents forced people into imaginative alternatives
  14. 经典文学之三:鲁迅·故乡
  15. 号称下一代互联网的 Web3.0 到底是个啥?
  16. 【COPOD】Suppressing Poisoning Attacks on Federated Learning for Medical Imaging
  17. 在线24点计算器工具
  18. java里dialect_iBatis3基于方言(Dialect)的分页
  19. iOS xxx is missing from working copy
  20. 微信打开H5网页二维码无法识别的问题

热门文章

  1. 快速上手Linux核心命令(四):文件内容相关命令
  2. git版本管理使用指南(附带repo)
  3. 5 分钟全面掌握 Python 装饰器
  4. python双向链表
  5. 算法基础知识(考试复习)
  6. 动态服务器以及WSGI
  7. 动软代码生成器之模板功能介绍
  8. 漫步最优化四十——Powell法(上)
  9. matlab一致性检验程序,一致性检验的源程序.doc
  10. c读取txt文件_第93天:文件读写