centos6.5下安装mysql5.6

1、查看系统版本
[root@python ~]# uname -a
Linux python 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

2、下载mysql
下载地址:https://dev.mysql.com/downloads
这里选择下载MySQL-5.6.42-1.el6.x86_64.rpm-bundle.tar打包版本(因为系统是64位,建议安装64位的mysql,个人第一次安装的32位,一直报错,处理不掉)

3、查看自带的mysql,卸载
[root@python software]# rpm -qa | grep mysql
[root@python software]# rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64
注:不卸载的话会有一系类的报错

4、解压安装包
[root@python software]# tar -xvf MySQL-5.6.42-1.el6.x86_64.rpm-bundle.tar
[root@python software]# ll
total 585912
-rw-r--r--. 1 root root  228188160 Dec  5  2018 MySQL-5.6.42-1.el6.x86_64.rpm-bundle.tar
-rw-r--r--. 1 7155 31415  19124980 Sep 11 17:03 MySQL-client-5.6.42-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415   3411264 Sep 11 17:03 MySQL-devel-5.6.42-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415  90167176 Sep 11 17:03 MySQL-embedded-5.6.42-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415  57600260 Sep 11 17:04 MySQL-server-5.6.42-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415   1973900 Sep 11 17:04 MySQL-shared-5.6.42-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415   3969756 Sep 11 17:04 MySQL-shared-compat-5.6.42-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415  51929752 Sep 11 17:04 MySQL-test-5.6.42-1.el6.x86_64.rpm

5、安装
[root@python software]# rpm -ivh MySQL-server-5.6.42-1.el6.x86_64.rpm
[root@python software]# rpm -ivh MySQL-client-5.6.42-1.el6.x86_64.rpm
这里可能会报错,缺少依赖
解决缺少perl的依赖:
[root@python software]# yum install -y perl

解决缺少libaio.so.1(64bit)的依赖:
这里使用yum install -y libaio.so.1后发现并不能解决问题,原因yum安装的并非x86_64版本,而是i686版本
[root@python software]# rpm -qa | grep libaio
libaio-0.3.107-10.el6.i686
手动下载libaio-0.3.107-10.el6.x86_64.rpm,下载地址如下:
http://mirror.centos.org/cent...
上传后安装
[root@python software]# rpm -ivh libaio-0.3.107-10.el6.x86_64.rpm

解决缺少libnuma.so.1(64bit)依赖:
[root@python software]# yum install -y numactl

这里因为在安装之前主动安装了依赖,所以实际安装中我并没有遇到报错
下面执行安装mysql_install_db时需要先安装perl-Module-Install.noarch
[root@python software]#yum install -y perl-Module-Install.noarch
还需要安装以下依赖
[root@python software]#yum install libaio*

安装完成后提示默认为root用户设置了随机密码,可以在/root/.mysql_secret文件中找到,并且移除了匿名用户,可以运行/usr/bin/mysql_secure_installation命令来移除自带的测试数据库,还生成了默认配置文件/usr/my.cnf

6、启动mysql设置root密码
启动服务
[root@python software]#service mysql start
查看默认生成的随机密码
[root@python software]# cat /root/.mysql_secret
# The random password set for the root user at Wed Dec  5 11:54:50 2018 (local time): V1yB2fDbI2RdoL7z
使用随机密码登录
mysql -u root -p
修改密码
mysql> set password = password('pass');
Query OK, 0 rows affected (0.10 sec)

7、开启mysql的远程登录(这里本人没有设置,网上的建议)
默认情况下mysql为安全起见,不支持远程登录mysql,因此需要设置开启远程登录mysql的权限
登录mysql后输入如下命令:
mysql> grant all privileges on *.* to 'root' @'%' identified by 'pass';
mysql> flush privileges;

8、设置开机自启
[root@python software]#chkconfig --add mysql
[root@python software]#chkconfig --list
[root@python software]#chkconfig mysql on

9、开放Linux的对外访问的端口3306
[root@python software]# /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
[root@python software]# /etc/rc.d/init.d/iptables save

10、删除测试库
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.09 sec)

[root@python software]# /usr/bin/mysql_secure_installation
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): 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] n ... skipping.

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] n ... skipping.

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] y

Dropping test database... ... Success!
Removing privileges on test database... ... Success!
Reloading the privilege tables will ensure that all changes made so
far will take effect immediately.

Reload privilege tables now? [Y/n] y ... Success!

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

Thanks for using MySQL!

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值