08 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版本
[root@localhost ~]# uname –a 位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包
[root@localhost 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. 更改安装包权限
解压缩后的安装包只有读写的权限,需要将其更改为可读可写可执行
[root@localhost 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
[root@localhost Linux]# chmod 744 -R MySQL
[root@localhost Linux]# cd MySQL/
[root@localhost 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
[root@localhost 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-*这个包卸载掉。
[root@localhost ~]# rpm -qa |grep -i mysql 注:查看系统下有哪些包含MySQL字符串的包
mysql-libs-5.1.71-1.el6.x86_64
[root@localhost ~]#
[root@localhost ~]# rpm -ev --nodeps mysql-libs-5.1.71-1.el6.x86_64 注:卸载mysql-libs-5.1.71-1.el6.x86_64包
[root@localhost ~]# cd /root/Linux/MySQL/
[root@localhost 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
[root@localhost 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
[root@localhost 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
[root@localhost MySQL]#
f. 创建mysql组
[root@localhost MySQL]# groupadd mysql
创建mysql用户,并添加到mysql组中
[root@localhost MySQL]# useradd -g mysql mysql
g. 查看root密码
[root@localhost 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的安装目录
[root@localhost mysql]# whereis mysql
mysql: /usr/bin/mysql /usr/lib64/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz
i. 查看Mysql的运行目录
[root@localhost MySQL]# which mysql
/usr/bin/mysql
3. 启动MySQL
a. 启动Mysql服务
[root@localhost MySQL]# service mysql start
Starting MySQL SUCCESS!
b. 查看Mysql是否启动
[root@localhost 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. 查看正在运行的端口号
[root@localhost 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 注是Mysql默认的端口号
2004/mysqld
udp 0 0 0.0.0.0:631 0.0.0.0:*
......
d. 首次启动Mysql
[root@localhost 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
[root@localhost 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
[root@localhost 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
[root@localhost mysql]#
08 Linux下MySQL的下载、安装及启动的更多相关文章
- linux下mysql基础从安装到基本使用
在LINUX下安装MYSQL #需要的安装包(按照先后顺序) libdbi-devel--2.1 libdbi--2.1 libdbi-drivers- perl-DBI-.el5 perl-DBD- ...
- linux下mysql多实例安装
1.MySQL多实例介绍 1.1.什么是MySQL多实例 MySQL多实例就是在一台机器上开启多个不同的服务端口(如:3306,3307),运行多个MySQL服务进程,通过不同的socket监听不同的 ...
- linux下mysql多实例安装(转)
转自:http://www.cnblogs.com/xuchenliang/p/6843990.html 1.MySQL多实例介绍 1.1.什么是MySQL多实例 MySQL多实例就是在一台机器上 ...
- 三、Linux下mysql的完整安装
参考资料:http://www.cnblogs.com/fly1988happy/archive/2011/11/21/2257682.html http://www.cnblogs.com/xion ...
- linux下mysql源码安装
参考链接:http://blog.csdn.net/zqtsx/article/details/9378703 下载mysql安装包, 不会下载点这里 地址:ftp://mirror.switch.c ...
- ubantu32位 linux下hexedit的下载安装
Hexedit软件介绍: hexedit是一个开源的完全免费的命令行软件,可用于在任何GNU / Linux操作系统下以十六进制和ASCII(美国信息交换标准代码)格式查看和编辑文件. 下载: 在so ...
- Windows下Nginx的下载安装、启动停止和配置浏览
前言: 记录一下今天在Windows下载安装Nginx服务器的过程.因为网上关于Nginx的资料都太复杂了,大多数是在Linux下使用的方法. 1.下载 Nginx官网下载地址:http://ngin ...
- linux 下mysql多实例安装
1.软件下载 https://dev.mysql.com/downloads/file/?id=479096 免编译二进制包 mysql-5.6.21-linux-glibc2.5-x86_64.ta ...
- linux下mysql 最新版安装图解教程
1.查看当前安装的linux版本 命令:lsb_release -a 如下图所示 通过上图中的数据可以看出安装的版本为RedHat5.4,所以我们需要下载RedHat5.4对应的mysql安装包 2. ...
随机推荐
- shell脚本 gawk语言 综采话单 对账 字段核对
今天被分配到对账组下的字段程序的了解和修改,在 SecureCRT 下的 run.sh 是字段对账的主程序,其中run.sh文件中含有gawk的代码. 程序的主要功能为 有两个文件夹 source存的 ...
- 华为"128为大整数相加"机试题
最近正直春招,偶尔接触到了华为的这道大整数相加的测试题,在网上找了一个算法,然后自己尝试进行了优化,最后也对memmove()函数效率有了进一步把握. #include <time.h># ...
- jquery保存用户名和密码到cookie里面
http://blog.sina.com.cn/s/blog_633ad0ae0101guij.html
- 1-2 ISO/OSI七层模型简介
相关名词解释: ISO:国际标准化组织 OSI:开放系统互联模型 IOS:苹果操作系统, 但是在计算机网络中,IOS是互联网操作系统,是思科公司为其网络设备开发的操作维护系统 <1>OSI ...
- svn 安装 、使用(1)
写在开头: 虽然网络极大的方便了我们查找答案,而且有很多人写各样的博客.但每个人在实际中的情况不一样,遇到的问题也不一样,大牛们会把步骤写的很简单,可能真的是怕麻烦,但显然就有一些东西已经不适合一部分 ...
- hdu1827 强连通
题意:一个人需要联系其他所有人,已知他自己联系每个人的花费,并且他可以联系某个人再让他联系他能联系到的人,给出一系列关系表示 A 能够联系 B.问他最少需要联系多少人,花费多少钱 首先,建成一个有向图 ...
- 英语语法最终珍藏版笔记- 21it 用法小结
it 用法小结 it 在英语中的意思较多,用法较广,现总结如下. 一.it作句子的真正主语 1.it 指前面已经提到过的人或事物,有时指心目中的或成为问题的人或事物,作真正主语. 例如: What’s ...
- K650D安装黑苹果
1.需要UEFI+GPT模式的win8或win10 2.关闭UEFI模式,进PE,分一个400M的分区,格式化为FAT16或EFI模式 3.制作clover模式的MAC安装U盘:链接: http:// ...
- Linux下串口与工业协议的开发
1.串口通信原理 串口通信定义 串口通信:数据的串行传送方式.串口通信可分为同步通信与异步通信. 同步通信:按照软件识别同步字符来实现数据的发送和接收. 将许多字符组成一个信息组进行发送 要求发送时钟 ...
- 用Spring的mappingDirectoryLocations来配置Hibernate映射文件
在Spring的applicationContext.xml中配置映射文件的方法: <property name="mappingResources"> < ...