CentOS6.6下使用rpm安装mysql5.6

 

一、卸载mysql: 
1、查找以前是否装有mysql 
#rpm -qa|grep -i mysql 
2、卸载mysql 
#yum remove mysql 
3、删除相关的包 
#yum remove 包名

 

二、

下载相应的mysql安装包

下载地址:http://dev.mysql.com/downloads/mysql/

Downloads->Community->MySQL CommunityServer

 

 

解压下载的mysql

tar -xf MySQL-5.6.22-1.el6.x86_64.rpm-bundle.tar

解压后的文件:

 

[root@bogon ftpuserLee]# ls

MySQL-5.6.22-1.el6.x86_64.rpm-bundle.tar        (原压缩包文件)

MySQL-client-5.6.22-1.el6.x86_64.rpm

MySQL-devel-5.6.22-1.el6.x86_64.rpm

MySQL-embedded-5.6.22-1.el6.x86_64.rpm

MySQL-server-5.6.22-1.el6.x86_64.rpm

MySQL-shared-5.6.22-1.el6.x86_64.rpm

MySQL-shared-compat-5.6.22-1.el6.x86_64.rpm

MySQL-test-5.6.22-1.el6.x86_64.rpm

 

 

 

 

 

(1)安装mysql服务(MySql-server) :

rpm -ivh/path/MySQL-server-5.6.14-1.e16.x86_64.rpm

出现如下提示,说明安装成功了。

注意,在Mysql-server安装完成后,要注意下面的提示,查看/root/.mysql_secret文件的内容,记录下其中l临时生成的密码:

A RANDOM PASSWORD HAS BEEN SETFOR THE MySQL root USER !

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

You must change that password onyour first connect,

no other statement but 'SETPASSWORD' will be accepted.

See the manual for the semanticsof the 'password expired' flag.

 

查看文件的内容:sudo cat /root/.mysql_secret

[root@bogonftpuserLee]# sudo cat /root/.mysql_secret

#The random password set for the root user at Tue Dec  2 15:24:58 2014 (local time):XwplZKfQuLd0PTrB

如果没有临时密码,在稍后的使用过程中会报如下异常:

希望读者注意这一点。

 

(2).安装mysql客户端(MySql-client):

rpm -ivp MySQL-client-5.6.14-1.el6.x86_64.rpm

出现如下提示说明,安装成功:

[root@bogonftpuserLee]# rpm -ivp MySQL-client-5.6.22-1.el6.x86_64.rpm

Preparingpackages for installation...

MySQL-client-5.6.22-1.el6

 

 

5.启动mysql服务

service mysql start

注意:这里面不是"servicemysqld start",在5.6这个版本里,命令和以前的有点区别。

 

启动mysql

[root@bogon ftpuserLee]# service mysql start

Starting MySQL.... SUCCESS!

6.启动客户端

mysql -u root -p

 

[root@bogon ftpuserLee]# mysql -u root -p

Enter password:

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

Your MySQL connection id is 1

Server version: 5.6.22

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

Oracle is a registered trademark of OracleCorporation and/or its

affiliates. Other names may be trademarks oftheir respective

owners.

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

这样就成功进入mysql客户端了!

7.这时候,你可以顺便把密码更改了:

set password for 'root'@'localhost' =password('新密码');

mysql> set password for 'root'@'localhost'= password('199028');

Query OK, 0 rows affected (0.03 sec)

8.创建数据库时生成的默认用户root只能在本机访问,需要对root用户授权为可以从所有远程主机访问:

mysql>grantall privileges on *.* to username01@'%' with grant option;

mysql> grant all privileges on *.* toroot@'%' with grant option;

Query OK, 0 rowsaffected (0.04 sec)

 

9.或者新增一个用户用来远程访问如果允许远程主机访问本机的mysql,需要另外增加一个用户:

mysql>createuser name01

mysql>grantall privileges on *.* to username01@'%' identified by '123456' with grant option;

授权用户username01能访问所有数据库下的所有数据表,密码为123456

flush配置使生效:
  mysql>FLUSH PRIVILEGES

10.

除了以上的安装方式为,也可以通过yum installmysql-server、yum install mysql-client命令来自动安装,安装的的默认版本为5.1.6。

你可能感兴趣的:(Linux,mysql)