返回顶部
首页 > 资讯 > 数据库 >Linux中怎么安装MySQL5.5
  • 684
分享到

Linux中怎么安装MySQL5.5

2024-04-02 19:04:59 684人浏览 安东尼
摘要

这篇文章将为大家详细讲解有关linux中怎么安装Mysql5.5,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。1.1 官方文档上有关mysql安装文件类型说

这篇文章将为大家详细讲解有关linux中怎么安装Mysql5.5,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。

1.1 官方文档上有关mysql安装文件类型说明:

Linux supports anumber of different solutions for installing Mysql. The recommended method isto use one of the distributions from oracle. If you choose this method, thereare three options available:

(1)Installingfrom a generic binary package in .tar.gz fORMat. See  for moreinformation.

(2)Extractingand compiling MySQL from a source distribution. For detailed instructions,see .

(3)Installingusing a pre-compiled RPM package. For more information on using the RPMsolution, see .

       --这里讲了3种方式来安装MySQL数据库,我这里用最简单的RPM 包来安装。

As analternative, you can use the native package manager within your Linuxdistribution to automatically download and install MySQL for you. Nativepackage installations can take of the download and dependencies required to runMySQL, but the MySQL version will often be some way behind the currentlyavailable release. You will also normally be unable to install developmentalreleases, as these are not usually made available in the native repository. Formore information on using the native package installers, see .

Note

For many Linux installations,you will want to set up MySQL to be started automatically when your Machinestarts. Many of the native package installations perform this operation foryou, but for source, binary and RPM solutions you may need to set this upseparately. The required script, ,can be found in the support-filesdirectory under the MySQL installationdirectory or in a MySQL source tree. You can install itas/etc/init.d/mysql for automatic MySQL startup and shutdown. See .

       --这里要注意一个问题,就是设置MySQL的自启动。 如果使用native package来安装,会自动设置为自启动,如果使用其他的方式,如source,binary和RPM,就需要单独的来设置自启动。

1.2 下载安装包

       我这里下载CommUnity Server 版的,Enterprise Edition版的请到Oracle E-Delivery上下载。Enterprise Edition 有30天的试用期。

   Community Server下载地址:

这里要注意的,MySQL的Tar 包还是比较大,要比RPM包大3倍左右。

MySQL 的RPM 包有如下几个:

看一下每个rpm 包具体的描述:

(1)MySQL-server-VERSION.glibc23.i386.rpm

The MySQLserver. You need this unless you only want to connect to a MySQL Server runninGon another machine.

(2)MySQL-client-VERSION.glibc23.i386.rpm

The standardMySQL client programs. You probably always want to install this package.

(3)MySQL-devel-VERSION.glibc23.i386.rpm

The librariesand include files that are needed if you want to compile other MySQL clients,such as the Perl modules.

(4)MySQL-debuginfo-VERSION.glibc23.i386.rpm

This packagecontains debugging information. debuginfo RPMs are never needed touse MySQL software; this is true both for the server and for client programs.However, they contain additional information that might be needed by a debuggerto analyze a crash.

(5)MySQL-shared-VERSION.glibc23.i386.rpm

This packagecontains the shared libraries (libmysqlclient.so*) that certain languages andapplications need to dynamically load and use MySQL. It containssingle-threaded and thread-safe libraries. Prior toMySQL 5.5.6, if you install this package, do not installthe MySQL-shared-compat package.

(6)MySQL-shared-compat-VERSION.glibc23.i386.rpm

This packageincludes the shared libraries for MySQL 3.23, 4.0, and so on. It containssingle-threaded and thread-safe libraries. Install this package if you have applicationsinstalled that are dynamically linked against older versions of MySQL but youwant to upgrade to the current version without breaking the librarydependencies. Before MySQL 5.5.6, MySQL-shared-compat also includesthe libraries for the current release, so if you install it, you should notalso install MySQL-shared. As of 5.5.6, MySQL-shared-compat doesnot include the current library version, so there is no conflict.

(7)MySQL-embedded-VERSION.glibc23.i386.rpm

The embeddedMySQL server library.

(8)MySQL-test-VERSION.glibc23.i386.rpm

This packageincludes the MySQL test suite.

(9)MySQL-VERSION.src.rpm

This containsthe source code for all of the previous packages. It can also be used torebuild the RPMs on other architectures (for example, Alpha or SPARC).

二. 安装MySQL

2.1 安装说明

(1)MySQL的安装包有很多个,作用也不同,在大多数情况下,只需要安装MySQL-server 和 MySQL-client,其他的包根据需要来安装。

(2)The server RPM places data underthe /var/lib/mysql directory. The RPM also creates a login accountfor a user named mysql (if one does not exist) to use for running theMySQL server, and creates the appropriate entries in /etc/init.d/ tostart the server automatically at boot time. (This means that if you haveperformed a previous installation and have made changes to its startup script,you may want to make a copy of the script so that you do not lose it when youinstall a newer RPM.) 

(3)During RPM installation, a usernamed mysql and a group named mysql are created on thesystem. This is done using the useradd, groupadd,and usermod commands. Those commands require appropriateadministrative privileges, which is required for locally managed users andgroups (as listed in the /etc/passwd and /etc/groupfiles) by theRPM installation process being run by root.

       --在MySQL 安装时,会创建mysql 用户和mysql组。

(4)MySQL 的相关目录说明

/usr/bin : Client programs and scripts    -- mysqladmin mysqldump等命令

/usr/sbin:  The  server

/var/lib/mysql: Log files, databases  --这个目录就是数据库的目录

/usr/share/info: Manual in Info format

/usr/share/man: Unix manual pages

/usr/include/mysql: Include (header) files

/usr/lib/mysql: Libraries

/usr/share/mysql : Miscellaneous support files,including error messages, character set files, sample configuration files, SQLfor database installation

               --mysql.server命令及配置文件

/usr/share/sql-bench: Benchmarks

/etc/rc.d/init.d/: 启动脚本文件mysql的目录

2.2 安装

--安装Server端:

[root@rac2 software]# ls

MySQL-client-5.5.15-1.rhel5.x86_64.rpm

MySQL-devel-5.5.15-1.rhel5.x86_64.rpm

MySQL-embedded-5.5.15-1.rhel5.x86_64.rpm

MySQL-server-5.5.15-1.rhel5.x86_64.rpm

MySQL-shared-5.5.15-1.rhel5.x86_64.rpm

MySQL-shared-compat-5.5.15-1.rhel5.x86_64.rpm

MySQL-test-5.5.15-1.rhel5.x86_64.rpm

[root@rac2 software]# rpm -ivh MySQL-server-5.5.15-1.rhel5.x86_64.rpm

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

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

PLEASE REMEMBER TO SET A PASSWord FOR THEMySQL root USER !

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

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

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

Alternatively you can run:

/usr/bin/mysql_secure_installation

which will also give you the option ofremoving the test

databases and anonymous user created bydefault.  This is

strongly recommended for productionservers.

See the manual for more instructions.

Please report any problems with the /usr/bin/mysqlbugscript!

[root@rac2 software]#

--- 安装客户端

[root@rac2 software]# rpm -ivh MySQL-client-5.5.15-1.rhel5.x86_64.rpm

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

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

2.3 其他操作

2.3.1 查看在时创建的mysql用户和mysql group:

[root@rac2 bin]# cat /etc/passwd|grep mysql

mysql:x:103:106:MySQLserver:/var/lib/mysql:/bin/bash

[root@rac2 bin]# cat /etc/group | grepmysql

mysql:x:106:

2.3.2 修改密码

--连接MySQL 报错:

[root@rac2 software]# mysql

ERROR 2002 (HY000): Can't connect to localMySQL server through Socket '/var/lib/mysql/mysql.sock' (2)

--启动MySQL 后,在连正常:

[root@rac2 ~]# /etc/init.d/mysql start

Starting MySQL...                                          [  OK  ]

[root@rac2 init.d]# mysql

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

Your MySQL connection id is 1

Server version: 5.5.15 MySQL CommunityServer (GPL)

Copyright (c) 2000, 2010, Oracle and/or itsaffiliates. All rights reserved.

Oracle is a reGIStered trademark of OracleCorporation and/or its

affiliates. Other names may be trademarksof their respective

owners.

Type 'help;' or '\h' for help. Type '\c' toclear the current input statement.

mysql>

--注意这里,因为MySQL默认没有密码,所以这里我们没有输入密码就直接连上了。

--修改密码,这个是安装Server 中提示的:

[root@rac2 ~]# /usr/bin/mysqladmin -u root password root

[root@rac2 ~]# mysql

ERROR 1045 (28000): Access denied for user'root'@'localhost' (using password: NO)

--修改密码之后,就提示要使用密码了。

[root@rac2 ~]# mysql -u root -p

Enter password:

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

Your MySQL connection id is 5

Server version: 5.5.15 MySQL CommunityServer (GPL)

Copyright (c) 2000, 2010, Oracle and/or itsaffiliates. All rights reserved.

Oracle is a registered trademark of OracleCorporation and/or its affiliates. Other names may be trademarks of theirrespective owners.

Type 'help;' or '\h' for help. Type '\c' toclear the current input statement.

mysql>

--输入密码后成功连接。

2.3.3 查看MySQL端口 3306, 这个是默认端口:

[root@rac2 ~]# netstat -nat|grep 3306

tcp       0      0 192.168.3.100:32842         192.168.3.100:3306          TIME_WAIT  

tcp       0      0 :::3306                     :::*                        LISTEN     

2.3.4 设置开机自启动

--查看MySQL 开机自启动设置:

[root@rac2 ~]# chkconfig --list |grep mysql

mysql           0:off   1:off  2:on    3:on    4:on   5:on    6:off

这里的数字分别代表启动的不同模式,3是命令行,5是窗口。

--关闭开机自启动

[root@rac2 ~]# chkconfig mysql off

[root@rac2 ~]# chkconfig --list |grep mysql

mysql          0:off   1:off  2:off   3:off   4:off  5:off   6:off

--启用开机自启动:

[root@rac2 ~]# chkconfig mysql on

[root@rac2 ~]# chkconfig --list |grep mysql

mysql           0:off   1:off  2:on    3:on    4:on   5:on    6:off

[root@rac2 ~]#

--将Mysql 从chkconfig服务里删除:

[root@rac2 ~]# chkconfig --del mysql

[root@rac2 ~]# chkconfig --list |grep mysql

--将Mysql 添加到chkconfig里:

[root@rac2 ~]# chkconfig --add mysql      

[root@rac2 ~]# chkconfig --list |grep mysql

mysql           0:off   1:off  2:on    3:on    4:on   5:on    6:off

2.4 操作

[root@rac2 ~]#  -u root -p

Enter password:

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

Your MySQL connection id is 6

Server version: 5.5.15 MySQL CommunityServer (GPL)

Copyright (c) 2000, 2010,  and/or itsaffiliates. All rights reserved.

Oracle is a registered trademark of OracleCorporation and/or its

affiliates. Other names may be trademarksof their respective

owners.

Type 'help;' or '\h' for help. Type '\c' toclear the current input statement.

--查看已经存在的数据库,这几个是安装时自动创建的

mysql> show databases;

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

| Database           |

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

| information_schema |

| mysql              |

| performance_schema |

| test               |

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

4 rows in set (0.00 sec)

--使用mysql 数据库

mysql> use mysql

Reading table information for completion oftable and column names

You can turn off this feature to get aquicker startup with -A

Database changed

--查看mysql 数据库下面的表

mysql> show tables;

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

| Tables_in_mysql           |

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

| columns_priv              |

| db                        |

| event                     |

| func                      |

| general_log               |

| help_category             |

| help_keyword              |

| help_relation             |

| help_topic                |

| host                      |

| ndb_binlog_index          |

| plugin                    |

| proc                      |

| procs_priv                |

| proxies_priv              |

| servers                   |

| slow_log                  |

| tables_priv               |

| time_zone                 |

| time_zone_leap_second     |

| time_zone_name            |

| time_zone_transition      |

| time_zone_transition_type |

| user                      |

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

24 rows in set (0.01 sec)

--创建数据库Dave

mysql> create database dave;

Query OK, 1 row affected (0.01 sec)

--在dave 数据库下面创建dave表:

mysql> use dave;

Database changed

mysql> create table dave(id int,namechar(20));

Query OK, 0 rows affected (0.01 sec)

--查看dave 表结构:

mysql> desc dave;

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

| Field | Type     | Null | Key | Default | Extra |

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

| id   | int(11)  | YES  |     | NULL   |       |

| name | char(20) | YES  |     | NULL   |       |

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

2 rows in set (0.00 sec)

--向dave 表里插入2条记录:

mysql> insert into davevalues(1,'dave');

Query OK, 1 row affected (0.00 sec)

mysql> insert into davevalues(2,'anqing');

Query OK, 1 row affected (0.01 sec)

mysql> select * from dave;

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

| id  | name   |

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

|   1 | dave   |

|   2 | anqing |

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

2 rows in set (0.00 sec)

--update 表:

mysql> update dave set name='david dai'where id=1;

Query OK, 1 row affected (0.01 sec)

Rows matched: 1  Changed: 1 Warnings: 0

mysql> select * from dave;

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

| id  | name      |

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

|   1 | david dai |

|   2 | anqing    |

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

2 rows in set (0.00 sec)

--drop 表:

mysql> drop table dave;

Query OK, 0 rows affected (0.01 sec)

--drop 数据库:

mysql> drop database dave;

Query OK, 0 rows affected (0.00 sec)

mysql> show databases;

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

| Database           |

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

| information_schema |

| mysql              |

| performance_schema |

| test               |

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

4 rows in set (0.01 sec)

关于Linux中怎么安装MySQL5.5就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

您可能感兴趣的文档:

--结束END--

本文标题: Linux中怎么安装MySQL5.5

本文链接: https://lsjlt.com/news/56905.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
  • Linux中怎么安装MySQL5.5
    这篇文章将为大家详细讲解有关Linux中怎么安装MySQL5.5,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。1.1 官方文档上有关MySQL安装文件类型说...
    99+
    2024-04-02
  • FreeBSD中怎么编译安装mysql5.5
    FreeBSD中怎么编译安装mysql5.5,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。 如果您的系统没有安装cmake,首先,cma...
    99+
    2024-04-02
  • linux64bit下怎么安装mysql5.5
    这篇文章主要介绍“linux64bit下怎么安装mysql5.5”,在日常操作中,相信很多人在linux64bit下怎么安装mysql5.5问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望...
    99+
    2024-04-02
  • mysql5.5 for linux的安装步骤
    本篇内容主要讲解“mysql5.5 for linux的安装步骤”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“mysql5.5 for linux的安装步骤”吧...
    99+
    2024-04-02
  • Linux Centos7安装MySQL5.5(二进制方式安装)
    Linux Centos7安装MySQL5.5(二进制方式安装) 一、在/app目录下下载mysql-5.5.54-linux2.6-x86_64.tar.gz` [root@test /]# cd /ap...
    99+
    2024-04-02
  • MySQL5.5源码安装
    1.创建运行用户 useradd -M -s /sbin/nologin mysql //新建程序用户并加入mysql组,不允许登陆系统 2.解包 cd ...
    99+
    2024-04-02
  • mysql5.5为什么安装不了
    这篇文章将为大家详细讲解有关mysql5.5为什么安装不了,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。mysql5.5安装不了的解决办法:首先卸载MySQL;然后删除安...
    99+
    2024-04-02
  • MySQL5.5 多实例安装
    一.多实例介绍1.1什么是MySQL多实例    简单的说,就是在一台服务器上开启不同的端口,运行多个MySQL服务进程,这些服务进程通过不同的socket监听不同的服务端口来提供各自的...
    99+
    2024-04-02
  • 安装MySQL5.5的方法
    安装MySQL5.5的方法?这个问题可能是我们日常学习或工作经常见到的。希望通过这个问题能让你收获颇深。下面是小编给大家带来的参考内容,让我们一起来看看吧!安装MySQL5.5的步骤:1、 官网下载mysq...
    99+
    2024-04-02
  • MySQL5.5版本安装失败怎么解决
    这篇文章主要介绍“MySQL5.5版本安装失败怎么解决”,在日常操作中,相信很多人在MySQL5.5版本安装失败怎么解决问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”MySQ...
    99+
    2023-03-15
    mysql
  • Mysql5.5编译安装步骤
    这篇文章主要介绍“Mysql5.5编译安装步骤”,在日常操作中,相信很多人在Mysql5.5编译安装步骤问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Mysql5.5编译安装...
    99+
    2024-04-02
  • mysql5.5、5.6自动化安装脚本怎么写
    mysql5.5、5.6自动化安装脚本怎么写,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。使用环境:①CentOS6 &...
    99+
    2024-04-02
  • MySQL5.5源码安装的流程
    这篇文章主要讲解了“MySQL5.5源码安装的流程”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“MySQL5.5源码安装的流程”吧! ...
    99+
    2024-04-02
  • MySQL5.5编译方式安装实战
    第一章 安装cmake[root@oldboy ~]# mkdir -p /home/oldboy/tools [root@oldboy ~]# ...
    99+
    2024-04-02
  • MySQL5.5多实例编译安装——mysqld_multi
    一、MySQL多实例简介MySQL多实例,简单地说,就是在一台服务器上同时开启多个不同的服务端口(如:3306、3307),同时运行多个MySQL服务进程,这些服务进程通过不同的socket监听来自不同的端...
    99+
    2024-04-02
  • CentOS安装MySQL5.5的完整步骤
    目录一 、安装前准备、安装包下载1 准备安装2 下载安装包二、开始安装1 将tar安装包上传到CentOS并解压2 移动到/usr/local目录下并改名3 增加MySQL配置文件4...
    99+
    2024-04-02
  • MySQL5.5版本安装详细讲解
    MySQL5.5版本安装详细讲解 1.打开下载的安装文件,出现如下界面,mysql安装向导启动,点击“next”继续 2.同意协议,点击“next”继续 3.选择安装类型 Typical----默认安装 2.Custom----完...
    99+
    2023-08-18
    mysql 数据库 java 青少年编程 经验分享
  • MySQL5.5版本安装与安装失败详细讲解
    目录mysql5.5版本安装详细讲解安装失败的情况总结 MySQL5.5版本安装详细讲解 1.打开下载的安装文件,出现如下界面,mysql安装向导启动,点击“next”继续 2.同意协...
    99+
    2023-03-13
    mysql5.5版本安装教程 mysql5.5版本安装 mysql5.5 安装
  • MySQL5.5基于CentOS6二进制包安装是怎么样的
    MySQL5.5基于CentOS6二进制包安装是怎么样的,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。1. 背景   ...
    99+
    2024-04-02
  • Linux中怎么安装RabbitMQ
    这篇文章主要介绍“Linux中怎么安装RabbitMQ”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“Linux中怎么安装RabbitMQ”文章能帮助大家解决问题。安...
    99+
    2024-04-02
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作