Linux下MySQL的下载、安装及启动

测试环境

主机系统:Win7 64位

虚拟机:VMware® Workstation 11.1.0

虚拟机系统:CentOS 6.5 64位   Kernel 2.6.32-431.e16.x86_64

MySQL: 5.6.24

1. Mysql的下载

a. 官网  http://dev.mysql.com/downloads/mysql/5.6.html#downloads

b. 下载跟OS对应的mysql版本

[[email protected] ~]# uname –a                           注:查看Linux版本信息,我这里是64位Linux系统

Linux localhost.localdomain 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

c. 在下拉列表选择Linux-Generic,下载64位的安装包

2. Mysql的安装

a. 将下载好的mysql制作成光盘镜像

不清楚的可以参考文章  Linux 下安装JDK并测试开发"Hello World!"

b. 解压缩tar包

[[email protected] MySQL]# tar -xvf MySQL-5.6.24-1.linux_glibc2.5.x86_64.rpm-bundle.tar
MySQL-shared-compat-5.6.24-1.linux_glibc2.5.x86_64.rpm
MySQL-test-5.6.24-1.linux_glibc2.5.x86_64.rpm
MySQL-devel-5.6.24-1.linux_glibc2.5.x86_64.rpm
MySQL-client-5.6.24-1.linux_glibc2.5.x86_64.rpm
MySQL-embedded-5.6.24-1.linux_glibc2.5.x86_64.rpm
MySQL-server-5.6.24-1.linux_glibc2.5.x86_64.rpm
MySQL-shared-5.6.24-1.linux_glibc2.5.x86_64.rpm

加压缩后这里有好几个rpm包,我们只要安装如下两个包即可

MySQL-server-5.6.24-1.linux_glibc2.5.x86_64.rpm

MySQL-client-5.6.24-1.linux_glibc2.5.x86_64.rpm

c. 更改安装包权限

解压缩后的安装包只有读写的权限,需要将其更改为可读可写可执行

[[email protected] MySQL]# ll
total 622244
-rwxr--r--. 1 root root  316661760 May 26 02:11 MySQL-5.6.24-1.linux_glibc2.5.x86_64.rpm-bundle.tar
-rw-r--r--. 1 7155 wheel  23066213 Mar 26 03:57 MySQL-client-5.6.24-1.linux_glibc2.5.x86_64.rpm
-rwxr--r--. 1 root root    3848304 May 26 02:11 mysql-connector-java-5.1.35.tar.gz
-rw-r--r--. 1 7155 wheel   4571173 Mar 26 03:57 MySQL-devel-5.6.24-1.linux_glibc2.5.x86_64.rpm
-rw-r--r--. 1 7155 wheel 117570910 Mar 26 03:57 MySQL-embedded-5.6.24-1.linux_glibc2.5.x86_64.rpm
-rw-r--r--. 1 7155 wheel  88668065 Mar 26 03:58 MySQL-server-5.6.24-1.linux_glibc2.5.x86_64.rpm
-rw-r--r--. 1 7155 wheel   2410130 Mar 26 03:59 MySQL-shared-5.6.24-1.linux_glibc2.5.x86_64.rpm
-rw-r--r--. 1 7155 wheel   5180642 Mar 26 03:59 MySQL-shared-compat-5.6.24-1.linux_glibc2.5.x86_64.rpm
-rw-r--r--. 1 7155 wheel  75180190 Mar 26 03:59 MySQL-test-5.6.24-1.linux_glibc2.5.x86_64.rpm

[[email protected] Linux]# chmod 744 -R MySQL
[[email protected] Linux]# cd MySQL/

[[email protected] MySQL]# ll
total 622244
-rwxr--r--. 1 root root  316661760 May 26 02:11 MySQL-5.6.24-1.linux_glibc2.5.x86_64.rpm-bundle.tar
-rwxr--r--. 1 7155 wheel  23066213 Mar 26 03:57 MySQL-client-5.6.24-1.linux_glibc2.5.x86_64.rpm
-rwxr--r--. 1 root root    3848304 May 26 02:11 mysql-connector-java-5.1.35.tar.gz
-rwxr--r--. 1 7155 wheel   4571173 Mar 26 03:57 MySQL-devel-5.6.24-1.linux_glibc2.5.x86_64.rpm
-rwxr--r--. 1 7155 wheel 117570910 Mar 26 03:57 MySQL-embedded-5.6.24-1.linux_glibc2.5.x86_64.rpm
-rwxr--r--. 1 7155 wheel  88668065 Mar 26 03:58 MySQL-server-5.6.24-1.linux_glibc2.5.x86_64.rpm
-rwxr--r--. 1 7155 wheel   2410130 Mar 26 03:59 MySQL-shared-5.6.24-1.linux_glibc2.5.x86_64.rpm
-rwxr--r--. 1 7155 wheel   5180642 Mar 26 03:59 MySQL-shared-compat-5.6.24-1.linux_glibc2.5.x86_64.rpm
-rwxr--r--. 1 7155 wheel  75180190 Mar 26 03:59 MySQL-test-5.6.24-1.linux_glibc2.5.x86_64.rpm

d. 安装Mysql-server

[[email protected] MySQL]# rpm -ivh MySQL-server-5.6.24-1.linux_glibc2.5.x86_64.rpm

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

file /usr/share/mysql/charsets/README from install of MySQL-server-5.6.24-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64

file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.6.24-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64

file /usr/share/mysql/danish/errmsg.sys from install of MySQL-server-5.6.24-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64

......

注:上面的报错信息意思是要安装的文件 MySQL-server-5.6.24-1.linux_glibc2.5.x86_64和系统文件mysql-libs-5.1.71-1.el6.x86_64有冲突

解决办法如下:

先查看系统下有哪些包含MySQL字符串的包,再把查到的mysql-libs-*这个包卸载掉。

[[email protected] ~]# rpm -qa |grep -i mysql                          注:查看系统下有哪些包含MySQL字符串的包

mysql-libs-5.1.71-1.el6.x86_64

[[email protected] ~]#

[[email protected] ~]# rpm -ev --nodeps mysql-libs-5.1.71-1.el6.x86_64               注:卸载mysql-libs-5.1.71-1.el6.x86_64包

[[email protected] ~]# cd /root/Linux/MySQL/

[[email protected] MySQL]# ls

MySQL-5.6.24-1.linux_glibc2.5.x86_64.rpm-bundle.tar

MySQL-client-5.6.24-1.linux_glibc2.5.x86_64.rpm

mysql-connector-java-5.1.35.tar.gz

MySQL-devel-5.6.24-1.linux_glibc2.5.x86_64.rpm

MySQL-embedded-5.6.24-1.linux_glibc2.5.x86_64.rpm

MySQL-server-5.6.24-1.linux_glibc2.5.x86_64.rpm

MySQL-shared-5.6.24-1.linux_glibc2.5.x86_64.rpm

MySQL-shared-compat-5.6.24-1.linux_glibc2.5.x86_64.rpm

MySQL-test-5.6.24-1.linux_glibc2.5.x86_64.rpm

[[email protected] MySQL]# rpm -ivh MySQL-server-5.6.24-1.linux_glibc2.5.x86_64.rpm                             注:安装MySQL-server

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

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

2015-05-26 03:50:44 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2015-05-26 03:50:44 0 [Note] /usr/sbin/mysqld (mysqld 5.6.24) starting as process 2931 ...

2015-05-26 03:50:44 2931 [Note] InnoDB: Using atomics to ref count buffer pool pages

2015-05-26 03:50:44 2931 [Note] InnoDB: The InnoDB memory heap is disabled

2015-05-26 03:50:44 2931 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

……

A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !

You will find that password in ‘/root/.mysql_secret‘.                                 注:root用户的mysql密码在这个文件中‘/root/.mysql_secret‘,第一次连接Mysql必须更改密码

You must change that password on your first connect,

no other statement but ‘SET PASSWORD‘ will be accepted.

See the manual for the semantics of the ‘password expired‘ flag.

e. 安装MySQL-Client

[[email protected] MySQL]# rpm -ivh MySQL-client-5.6.24-1.linux_glibc2.5.x86_64.rpm

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

package MySQL-client-5.6.24-1.linux_glibc2.5.x86_64 is already installed

[[email protected] MySQL]#

f. 创建mysql组

[[email protected] MySQL]# groupadd mysql

创建mysql用户,并添加到mysql组中

[[email protected] MySQL]# useradd -g mysql mysql

g. 查看root密码

[[email protected] mysql]# more /root/.mysql_secret

# The random password set for the root user at Tue May 26 03:50:49 2015 (local time

): fB0j9h3IOFdT9nf5                                            注:初始密码,fB0j9h3IOFdT9nf5

h. 查看MySQL的安装目录

[[email protected] mysql]# whereis mysql

mysql: /usr/bin/mysql /usr/lib64/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz

i. 查看Mysql的运行目录

[[email protected] MySQL]# which mysql
/usr/bin/mysql

3. 启动MySQL

a. 启动Mysql服务

[[email protected] MySQL]# service mysql start
Starting MySQL SUCCESS!

b. 查看Mysql是否启动

[[email protected] MySQL]# ps -ef | grep mysql
root       1904      1  0 18:53 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/localhost.localdomain.pid
mysql      2032   1904  0 18:53 ?        00:00:09 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/localhost.localdomain.err --pid-file=/var/lib/mysql/localhost.localdomain.pid
root       3797   2874  0 20:05 pts/0    00:00:00 grep mysql

usr/bin/mysql 是指:mysql的运行路径

var/lib/mysql 是指:mysql数据库文件的存放路径

usr/lib/mysql 是指:mysql的安装路径

c. 查看正在运行的端口号

[[email protected] mysql]# netstat -anp |more

Active Internet connections (servers and established)

Proto Recv-Q Send-Q Local Address Foreign Address State

PID/Program name

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN

1846/sshd

tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN

1668/cupsd

tcp 0 0 127.0.0.1:199 0.0.0.0:* LISTEN

1826/snmpd

tcp 0 0 :::22 :::* LISTEN

1846/sshd

tcp 0 0 ::1:631 :::* LISTEN

1668/cupsd

tcp 0 0 :::3306 :::* LISTEN                      注:3306是Mysql默认的端口号

2004/mysqld

udp 0 0 0.0.0.0:631 0.0.0.0:*

......

d. 首次启动Mysql

[[email protected] mysql]# more /root/.mysql_secret         注:root用户的mysql初始密码

# The random password set for the root user at Tue May 26 03:50:49 2015 (local time

): fB0j9h3IOFdT9nf5

[[email protected] mysql]# mysql -h node2 -uroot -pfB0j9h3IOFdT9nf5

Warning: Using a password on the command line interface can be insecure.

ERROR 2005 (HY000): Unknown MySQL server host ‘node2‘ (111) 报错                注:找不到node2

解决方法

将node2换成127.0.0.1

[[email protected] mysql]# mysql -h127.0.0.1 -uroot -pfB0j9h3IOFdT9nf5

Warning: Using a password on the command line interface can be insecure.

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

Your MySQL connection id is 2

Server version: 5.6.24

Copyright (c) 2000, 2015, 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已启动

e. 更改root密码为mysql

mysql> set password=password(‘mysql‘);              注:命令最后有分号

Query OK, 0 rows affected (0.09 sec)

mysql> flush privileges;                                           注: 刷新权限

Query OK, 0 rows affected (0.00 sec)

f. 查看数据库

mysql> show databases;

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

| Database |

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

| information_schema |

| mysql |

| performance_schema |

| test |

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

4 rows in set (0.09 sec)

mysql> exit                                          注:退出MySQL,自动切换至Linux root用户

Bye

[[email protected] mysql]#

时间: 2024-10-23 22:24:49

Linux下MySQL的下载、安装及启动的相关文章

Linux下Mysql 的编译安装最新版本5.6.24和详细部署

  MySQL 5.6正式版发布了,相对于5.5版本作出了不少改进,其源码安装配置方式也有所变化,本文根据实际操作,不断尝试,精确还原了安装的具体步骤. 安装MySQL前,先确认卸载系统自带数据库 打开操作终端 输入rpm -qa|grep mysql(罗列所有数据库相关的文件) rpm –e (罗列出来的文件)--nodeps(使用该命令依次删除罗列出来的文件)--nodeps为删除与之依赖的文件. 确认Internet连接正常,以便下载安装文件. 先使用 yum -y update 指令升级

Linux 下MySQL源码安装完整版

在Linux中安装MySQL,通常为RPM与源码方式安装.对于生产环境而言,由于需要自定义诸如安装路径.数据文件位置.字符集以及支持的存储引擎等多以源码方式来进行安装.之前有写过一篇关于源码安装的文章,Linux下基于源码方式安装MySQL 5.6,但不是很完整,因此该文可以作为其补充.以下为具体安装步骤,供大家参考. 1.安装前的有关描述必备的包和工具  gcc/g++ :MySQL 5.6开始,需要使用g++进行编译.  cmake  :MySQL 5.5开始,使用cmake进行工程管理,c

linux下mysql多实例安装(转)

转自:http://www.cnblogs.com/xuchenliang/p/6843990.html 1.MySQL多实例介绍 1.1.什么是MySQL多实例 MySQL多实例就是在一台机器上开启多个不同的服务端口(如:3306,3307),运行多个MySQL服务进程,通过不同的socket监听不同的服务端口来提供各自的服务:: 1.2.MySQL多实例的特点有以下几点 1:有效利用服务器资源,当单个服务器资源有剩余时,可以充分利用剩余的资源提供更多的服务. 2:节约服务器资源 3:资源互相

linux下mysql基础从安装到基本使用

在LINUX下安装MYSQL #需要的安装包(按照先后顺序) libdbi-devel-0.8.1-2.1 libdbi-0.8.1-2.1 libdbi-drivers-0.8.1a-1.2.2 perl-DBI-1.52-2.el5 perl-DBD-MySQL-3.0007-2.el5 mysql-5.0.77-4.el5_6.6 mysql-devel-5.0.77-4.el5_6.6 mysql-server-5.0.77-4.el5_6.6 mysql-test-5.0.77-4.e

三、Linux下mysql的完整安装

参考资料:http://www.cnblogs.com/fly1988happy/archive/2011/11/21/2257682.html http://www.cnblogs.com/xiongpq/p/3384681.html 一.安装cmake(mysql5.5.0之后的版本用cmake安装) 下载: cd /usr/local/src/ wget http://www.cmake.org/files/v3.3/cmake-3.3.0-rc4.tar.gz 安装: tar -zxvf

linux下mysql 最新版安装图解教程

1.查看当前安装的linux版本 命令:lsb_release -a 如下图所示 通过上图中的数据可以看出安装的版本为RedHat5.4,所以我们需要下载RedHat5.4对应的mysql安装包 2.下载mysql安装文件 官方网站下载安装包,因为本地RedHat版本为Red Hat 5.4,操作系统是64位的  所以在官方网站下载以下安装包 http://dev.mysql.com/downloads/mysql#downloads  MySQL-server-5.5.25a-1.rhel5.

linux下mysql远程连接配置和启动重启关闭

linux mysql远程连接 远程使用Navicat for mysql 客户端软件连接 mySql数据时,连接出现Can’t connect to MySQL on ’192.168.1.99’(10061)错误时,是由于MySQL不准许远程连接.修改方法如下: 1:在服务端MySQL/my.ini文件 或者/etc/mysql/my.cnf .修改bind-address=127.0.0.1 为 bind-address=0.0.0.0 2:重新启动MySQL服务.测试连接情况: 如果没有

linux下apache服务器的安装、启动、查看

一.apache的启动 apahce启动命令:/你的安装目录/apachectl start apaceh启动 apache停止命令/你的安装目录/apachectl stop   停止 apache重新启动命令:/你的安装目录/apachectl restart 重启 三.查看 netstat -nltup |grep httpd 查看本机上是否启动成功apache

linux下MySQL与jdk安装

允许本地访问端口:iptables -P OUTPUT ACCEPT1.yum install mysql 2.yum install mysql-server 3.删除MySQL数据库中user表中user为空的记录: 4.执行以下sql语句use mysql;mysql> UPDATE user SET password=password("root") WHERE user='root'; mysql> flush privileges;mysql> exit;