【MySQL学习笔记】CentOS 6.6上RPM包方式安装MySQL 5.6

1、首先第一步是安装好CentOS 6.6

先下载好centos 6.6,然后,在虚拟机中安装好系统。

需要安装vmware tools,由于VMware Tools这个目录中包含了空格,所以要用 \ 来转义空格:

 

[root@ggg1 Desktop]# cd /media/VMware\ Tools

[root@ggg1 Desktop]# tar -zvxf VMwareTools-9.2.0-799703.tar.gz -C /root/Desktop

 

安装后,就可以从LInux中复制粘贴。


2、下载MySQL 5.6

mysql的下载地址是在 网页 http://downloads.mysql.com/archives/community/ 中,我选择了MySQL 5.6.12版,具体的rpm包是:MySQL-server-5.6.12-2.el6.x86_64.rpm。

通过wget命令来下载,指定的下载地址是:http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-server-5.6.12-2.el6.x86_64.rpm

 

[root@wc1 Desktop]# wget http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-server-5.6.12-2.el6.x86_64.rpm
--2016-08-16 11:34:47--  http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-server-5.6.12-2.el6.x86_64.rpm
Resolving dev.mysql.com... 137.254.60.11
Connecting to dev.mysql.com|137.254.60.11|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://cdn.mysql.com//archives/mysql-5.6/MySQL-server-5.6.12-2.el6.x86_64.rpm [following]
--2016-08-16 11:34:49--  http://cdn.mysql.com//archives/mysql-5.6/MySQL-server-5.6.12-2.el6.x86_64.rpm
Resolving cdn.mysql.com... 104.102.164.25
Connecting to cdn.mysql.com|104.102.164.25|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 57355800 (55M) [application/x-redhat-package-manager]
Saving to: “MySQL-server-5.6.12-2.el6.x86_64.rpm”


100%[======================================>] 57,355,800   645K/s   in 3m 25s  


2016-08-16 11:38:15 (273 KB/s) - “MySQL-server-5.6.12-2.el6.x86_64.rpm” saved [57355800/57355800]


3、安装MySQL

 

运行如下命令来安装,但是并没有安装,显示有冲突,从字面的意思看出,大致上是我要安装的rpm包,和之前的mysql-libs-5.1.73-3.el6_5.x86_64 有冲突:

 

[root@wc1 Desktop]# rpm -ivh MySQL-server-5.6.12-2.el6.x86_64.rpm
Preparing...                ########################################### [100%]
	file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/danish/errmsg.sys from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/dutch/errmsg.sys from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/english/errmsg.sys from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/estonian/errmsg.sys from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/french/errmsg.sys from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/german/errmsg.sys from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/greek/errmsg.sys from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/hungarian/errmsg.sys from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/italian/errmsg.sys from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/japanese/errmsg.sys from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/korean/errmsg.sys from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/norwegian-ny/errmsg.sys from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/norwegian/errmsg.sys from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/polish/errmsg.sys from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/portuguese/errmsg.sys from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/romanian/errmsg.sys from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/russian/errmsg.sys from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/serbian/errmsg.sys from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/slovak/errmsg.sys from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/spanish/errmsg.sys from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/swedish/errmsg.sys from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/ukrainian/errmsg.sys from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/charsets/Index.xml from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/charsets/armscii8.xml from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/charsets/ascii.xml from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/charsets/cp1250.xml from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/charsets/cp1256.xml from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/charsets/cp1257.xml from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/charsets/cp850.xml from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/charsets/cp852.xml from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/charsets/cp866.xml from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/charsets/dec8.xml from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/charsets/geostd8.xml from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/charsets/greek.xml from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/charsets/hebrew.xml from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/charsets/hp8.xml from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/charsets/keybcs2.xml from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/charsets/koi8r.xml from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/charsets/koi8u.xml from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/charsets/latin1.xml from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/charsets/latin2.xml from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/charsets/latin5.xml from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/charsets/latin7.xml from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/charsets/macce.xml from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/charsets/macroman.xml from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
	file /usr/share/mysql/charsets/swe7.xml from install of MySQL-server-5.6.12-2.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64


通过如下命令,删除mysql-libs包,同时忽略软件包的依赖关系:

 

 

[root@wc1 Desktop]# rpm -e mysql-libs --nodeps


再次尝试安装:

 

 

[root@wc1 Desktop]# rpm -ivh MySQL-server-5.6.12-2.el6.x86_64.rpm
Preparing...                ########################################### [100%]
   1:MySQL-server           ########################################### [100%]
2016-08-16 11:46:37 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-08-16 11:46:37 4680 [Note] InnoDB: The InnoDB memory heap is disabled
2016-08-16 11:46:37 4680 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-08-16 11:46:37 4680 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-08-16 11:46:37 4680 [Note] InnoDB: Using Linux native AIO
2016-08-16 11:46:37 4680 [Note] InnoDB: Using CPU crc32 instructions
2016-08-16 11:46:37 4680 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-08-16 11:46:37 4680 [Note] InnoDB: Completed initialization of buffer pool
2016-08-16 11:46:37 4680 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2016-08-16 11:46:37 4680 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2016-08-16 11:46:37 4680 [Note] InnoDB: Database physically writes the file full: wait...
2016-08-16 11:46:38 4680 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2016-08-16 11:46:39 4680 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2016-08-16 11:46:40 4680 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2016-08-16 11:46:40 4680 [Warning] InnoDB: New log files created, LSN=45781
2016-08-16 11:46:40 4680 [Note] InnoDB: Doublewrite buffer not found: creating new
2016-08-16 11:46:40 4680 [Note] InnoDB: Doublewrite buffer created
2016-08-16 11:46:40 4680 [Note] InnoDB: 128 rollback segment(s) are active.
2016-08-16 11:46:40 4680 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-08-16 11:46:40 4680 [Note] InnoDB: Foreign key constraint system tables created
2016-08-16 11:46:40 4680 [Note] InnoDB: Creating tablespace and datafile system tables.
2016-08-16 11:46:40 4680 [Note] InnoDB: Tablespace and datafile system tables created.
2016-08-16 11:46:40 4680 [Note] InnoDB: Waiting for purge to start
2016-08-16 11:46:40 4680 [Note] InnoDB: 5.6.12 started; log sequence number 0
A random root password has been set. You will find it in '/root/.mysql_secret'.
2016-08-16 11:46:42 4680 [Note] Binlog end
2016-08-16 11:46:42 4680 [Note] InnoDB: FTS optimize thread exiting.
2016-08-16 11:46:42 4680 [Note] InnoDB: Starting shutdown...
2016-08-16 11:46:44 4680 [Note] InnoDB: Shutdown completed; log sequence number 1625977


2016-08-16 11:46:44 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-08-16 11:46:44 4705 [Note] InnoDB: The InnoDB memory heap is disabled
2016-08-16 11:46:44 4705 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-08-16 11:46:44 4705 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-08-16 11:46:44 4705 [Note] InnoDB: Using Linux native AIO
2016-08-16 11:46:44 4705 [Note] InnoDB: Using CPU crc32 instructions
2016-08-16 11:46:44 4705 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-08-16 11:46:44 4705 [Note] InnoDB: Completed initialization of buffer pool
2016-08-16 11:46:44 4705 [Note] InnoDB: Highest supported file format is Barracuda.
2016-08-16 11:46:44 4705 [Note] InnoDB: 128 rollback segment(s) are active.
2016-08-16 11:46:44 4705 [Note] InnoDB: Waiting for purge to start
2016-08-16 11:46:44 4705 [Note] InnoDB: 5.6.12 started; log sequence number 1625977
2016-08-16 11:46:45 4705 [Note] Binlog end
2016-08-16 11:46:45 4705 [Note] InnoDB: FTS optimize thread exiting.
2016-08-16 11:46:45 4705 [Note] InnoDB: Starting shutdown...
2016-08-16 11:46:46 4705 [Note] InnoDB: Shutdown completed; log sequence number 1625987




A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.

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.

Also, the account for the anonymous user has been removed.

In addition, you can run:

  /usr/bin/mysql_secure_installation

which will also give you the option of removing the test database.
This is strongly recommended for production servers.

See the manual for more instructions.

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

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

[root@wc1 Desktop]# 

 

从上面的安装日志中,能够看到很多有用的信息,比如下面这3段,分别表示 mysql生成的随机密码是放在哪个文件中的,在第一次登录mysql后要使用 set password命令修改密码,创建了默认的配置文件my.cnf文件的路径:

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

You will find that password in '/root/.mysql_secret'.


You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.


New default config file was created as /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

至此,安装成功大笑


4、下载并安装MySQL 客户端

安装好了MySQL之后,我们需要连接到mysql,但是由于mysql-server并不包含客户端,所以还要下载客户端,客户端的rpm包名,只是把server改为clinet,其他的都一样。

先下载:

 

[root@wc1 Desktop]# wget http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-client-5.6.12-2.el6.x86_64.rpm
--2016-08-16 13:20:48--  http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-client-5.6.12-2.el6.x86_64.rpm
Resolving dev.mysql.com... 137.254.60.11
Connecting to dev.mysql.com|137.254.60.11|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://cdn.mysql.com//archives/mysql-5.6/MySQL-client-5.6.12-2.el6.x86_64.rpm [following]
--2016-08-16 13:20:50--  http://cdn.mysql.com//archives/mysql-5.6/MySQL-client-5.6.12-2.el6.x86_64.rpm
Resolving cdn.mysql.com... 23.42.233.185
Connecting to cdn.mysql.com|23.42.233.185|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 18527048 (18M) [application/x-redhat-package-manager]
Saving to: “MySQL-client-5.6.12-2.el6.x86_64.rpm”

100%[======================================>] 18,527,048   959K/s   in 31s     

2016-08-16 13:21:24 (582 KB/s) - “MySQL-client-5.6.12-2.el6.x86_64.rpm” saved [18527048/18527048]


然后安装:

 

 

[root@wc1 Desktop]# rpm -ivh MySQL-client-5.6.12-2.el6.x86_64.rpmPreparing...                ########################################### [100%]
   1:MySQL-client           ########################################### [100%]

另外,可以通过rpm -ql MySQL-client 命令,来查询系统上已安装的软件,还可以通过rpm -e MySQL-client 来删除软件。


5、启动mysql

 

[root@wc1 Desktop]# service mysql start
Starting MySQL....                                         [  OK  ]

 


检查是否开机自启动:

 

[root@wc1 Desktop]# chkconfig --list | grep mysql
mysql          	0:off	1:off	2:on	3:on	4:on	5:on	6:off

 


这里的0~6,分别表示不同的runlevel,比如:2是多用户模式(除了没有NFS),而3是标准的多用户模式。


如果没有设置,可以通过如下命令来设置:

 

[root@wc1 Desktop]# chkconfig mysql on


6、登录mysql

 

要登录mysql,就得有密码,而密码就在这个文件里 '/root/.mysql_secret',需要注意的是这个文件是以 点 开头的隐藏文件。

于是找到这个文件,这里ls的参数a 指显示所有隐藏的文件(包含以点开头的),而l 参数表示显示详细信息,grep命令可以用来过滤出包含某些字符(这里是secret)的信息,注意这里的密码是6g2niot5 

 

[root@wc1 ~]# ls -al | grep 'secret'
-rw-------.  1 root root    96 Aug 16 11:46 .mysql_secret
[root@wc1 ~]# cat .mysql_secret
# The random password set for the root user at Tue Aug 16 11:46:41 2016 (local time): 6g2niot5


登录mysql:

 

 

[root@wc1 ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.6.12 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> set password for root@"wc1.localdomain" = password("yupeigu");
Query OK, 1 rows affected (0.03 sec)

 

给用户授权,并刷新权限,这样就能立即生效:

 

mysql> grant all privileges on *.* to root@'%' identified by 'yupeigu' with grant option;
Query OK, 0 rows affected (0.03 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)


 

转载于:https://www.cnblogs.com/momogua/p/8304425.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值