centos6.X版本离线安装MySQL

准备工作

下载好安装文件:
在这里插入图片描述
在这里插入图片描述
上传到centos操作系统的~/downloads,没有该目录可以创建以下,以后把安装文件的安装包统一放到这里便于管理。

观察系统中是否安装过MySQL文件

[hadoop@s1 ~]$ rpm -qa | grep -i mysql   # i指的是不区分大小写
mysql-libs-5.1.73-3.el6_5.x86_64

可以观察到系统自带了一个MySQL文件

卸载该文件否则后续工作无法进行:

sudo rpm -e mysql-libs-5.1.73-3.el6_5.x86_64 --nodeps

安装MySQL-server

[hadoop@s1 ~]$ cd downloads/
[hadoop@s1 downloads]$ sudo rpm -ivh MySQL-server-5.1.73-1.glibc23.x86_64.rpm

观察MySQL端口号看看是否安装成功

[hadoop@s1 downloads]$ netstat -an | grep 3306
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN   

出现LISTEN说明没有问题

安装MySQL-Client

[hadoop@s1 downloads]$ sudo rpm -ivh MySQL-client-5.1.73-1.glibc23.x86_64.rpm 

操作MySQL

登录数据库

[hadoop@s1 downloads]$ mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.00 sec)

停止MySQL

[hadoop@s1 downloads]$ sudo service mysql stop
[sudo] password for hadoop: 
Shutting down MySQL..                                      [  OK  ]

开启MySQL服务

[hadoop@s1 downloads]$ sudo service mysql start
Starting MySQL.                                            [  OK  ]

设置开机自启

[hadoop@s1 downloads]$ sudo chkconfig mysql on

你可能感兴趣的:(大数据技术与应用)