CentOS 6.5下安装MySQL 5.6

5 篇文章 0 订阅
2 篇文章 0 订阅

1、 下载

下载地址:
https://dev.mysql.com/downloads/mysql/5.6.html#downloads

选择你需要安装的版本,这里我的电脑是CentOs 6.5x64位
这里写图片描述

然后下载 RPM Bundle,这个是几个程序的合集包。
这里写图片描述

然后开始下载。。。。

2、 解压安装包

解压MySQL-5.6.37-1.el6.x86_64.rpm-bundle.tar

 #tar -xvf MySQL-5.6.37-1.el6.x86_64.rpm-bundle.tar

 MySQL-embedded-5.6.37-1.el6.x86_64.rpm  
 MySQL-shared-compat-5.6.37-1.el6.x86_64.rpm
 MySQL-server-5.6.37-1.el6.x86_64.rpm
 MySQL-test-5.6.37-1.el6.x86_64.rpm
 MySQL-devel-5.6.37-1.el6.x86_64.rpm
 MySQL-shared-5.6.37-1.el6.x86_64.rpm
#ls

-rw-r--r--. 1 7155 31415  18894156 Jun  4  2017 MySQL-client-5.6.37-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415   3391760 Jun  4  2017 MySQL-devel-5.6.37-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415  90214216 Jun  4  2017 MySQL-embedded-5.6.37-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415  57482996 Jun  4  2017 MySQL-server-5.6.37-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415   1964816 Jun  4  2017 MySQL-shared-5.6.37-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415   3969752 Jun  4  2017 MySQL-shared-compat-5.6.37-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415  51776076 Jun  4  2017 MySQL-test-5.6.37-1.el6.x86_64.rpm

3、安装

卸载已安装的mysql-libs

# rpm -qa | grep -i mysql
mysql-libs-5.1.73-8.el6_8.x86_64

#yum remove mysql-libs

安装

# rpm -ivh  MySQL-shared-compat-5.6.37-1.el6.x86_64.rpm   --force --nodeps 
# rpm -ivh  MySQL-server-5.6.37-1.el6.x86_64.rpm 

warning: MySQL-server-5.6.37-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-server           ####################                        ( 47%)
   ...................
   2016-06-03 07:33:31 9531 [Note] InnoDB: Waiting for purge to start
2016-06-03 07:33:31 9531 [Note] InnoDB: 5.6.37 started; log sequence number 0
A random root password has been set. You will find it in '/root/.mysql_secret'.
2016-06-03 07:33:32 9531 [Note] Binlog end
2016-06-03 07:33:32 9531 [Note] InnoDB: FTS optimize thread exiting.
.............

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

安装日志里面有一句A random root password has been set. You will find it in ‘/root/.mysql_secret’.

安装时自动生成了随机密码,并保存在‘/root/.mysql_secret’,初次登录时需要重置密码。

# cat /root/.mysql_secret

The random password set for the root user at Fri Jun  3 07:33:32 2016 (local time): hbNyslmCsoidqRNd <- 得到root访问mysql的密码

安装客户端

#  rpm -ivh  MySQL-client-5.6.37-1.el6.x86_64.rpm   --force --nodeps 
#  rpm -ivh  MySQL-devel-5.6.37-1.el6.x86_64.rpm   --force --nodeps 

MySQL 的配置文件位于:/usr/my.cnf ,根据需求修改配置
默认的datadir=/var/lib/mysql

启动mysql

# service mysql start

4、初始化

# mysql -u root -p 
Enter password: 
mysql>

输入初始密码后,就可以登录了;
登录后需要重置密码,如果不重置,则不让操作

mysql> show databases;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement 

这里可以直接使用命令修改root用户密码

SET PASSWORD = PASSWORD('passwd');

但MySQL提供了一个向导,推荐使用:

#/usr/bin/mysql_secure_installation --user=mysql



NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): <- mysql的初始密码
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] Y  <- 是否更换root用户密码,建议更换
New password: <- 设置root用户的密码
Re-enter new password: <- 设置root用户的密码
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y  <- 是否删除匿名用户,生产环境建议删除
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y <- 是否禁止root远程登录,根据自己的需求选择Y/n并回车,建议禁止
 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] n  <- 是否删除test数据库,输入y并回车
 ... skipping.

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y <- 是否重新加载权限表,输入y并回车
 ... Success!




All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!


Cleaning up...

5、创建用户

登录

# mysql -u root -p 
Enter password: 
mysql>

创建数据库,指定编码utf-8:

mysql> CREATE DATABASE db182915 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

添加用户 test:

mysql> GRANT ALL PRIVILEGES ON db182915.* TO 'test'@'192.168.%' IDENTIFIED BY 'test123#' WITH GRANT OPTION;
mysql> flush privileges;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值