MySQL系列(一)CentOS6.8yum安装MySQL5.6


Mysql

1.1 环境

[root@linux-node1 ~]# cat /etc/redhat-release 
CentOS release 6.8 (Final)
[root@linux-node1 ~]# uname -a
Linux linux-node1.syaving.com 2.6.32-642.el6.x86_64 #1 SMP Tue May 10 17:27:01 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
[root@linux-node1 ~]# hostname 
linux-node1.syaving.com
[root@linux-node1 ~]# hostname -I
192.168.1.193

1.2 否安装其他版本的MySQL

[root@localhost ~]# yum list installed | grep mysql
mysql-libs.x86_64 5.1.73-7.el6 @anaconda-CentOS-201605220104.x86_64/6.8
[root@localhost ~]# yum -y remove mysql-libs.x86_64

1.3 下载新版本MySQL

[root@localhost ~]# wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
--2017-11-17 10:23:21-- http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
Resolving repo.mysql.com... 104.127.195.16
Connecting to repo.mysql.com|104.127.195.16|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5824 (5.7K) [application/x-redhat-package-manager]
Saving to: “mysql-community-release-el6-5.noarch.rpm”

100%[=======================================================================================================>] 5,824 --.-K/s in 0s

2017-11-17 10:23:21 (124 MB/s) - “mysql-community-release-el6-5.noarch.rpm” saved [5824/5824]

[root@localhost ~]# ll
total 8
-rw-r--r--. 1 root root 5824 Nov 12 2015 mysql-community-release-el6-5.noarch.rpm
[root@localhost ~]# rpm -ivh mysql-community-release-el6-5.noarch.rpm 
Preparing... ########################################### [100%]
1:mysql-community-release########################################### [100%]
[root@localhost ~]# yum list installed | grep mysql
mysql-community-release.noarch

1.4 安装MYSQL数据库

[root@localhost ~]# yum install mysql-community-server -y

1.5 修改MySQL密码

[root@localhost ~]# mysqladmin -uroot password '123456'
Warning: Using a password on the command line interface can be insecure.

1.6 进入MySQL

[root@localhost ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.38 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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>

1.7 查看MySQL版本

[root@localhost ~]# mysql -V

mysql  Ver 14.14 Distrib 5.6.38, for Linux (x86_64) using  EditLine wrapper

 1.8配置防火墙

默认防火墙的3306端口默认没有开启,若要远程访问,需要开启这个端口

[root@localhost ~]# vim /etc/sysconfig/iptables
#在“-A INPUT –m state --state NEW –m tcp –p –dport 22 –j ACCEPT”,下添加:
-A INPUT -m state --state NEW -m tcp -p -dport 3306 -j ACCEPT

然后保存,并关闭该文件,在终端内运行下面的命令,刷新防火墙配置:

[root@localhost ~]# service iptables restart

1.9 授权root用户可以远程连接

mysql> use mysql;
mysql> grant all privileges on *.* to 'root'@'%' identified by '123456';
mysql> flush privileges;

1.10 远程查看库

[root@localhost ~]# mysql -uroot -p123456 -h 192.168.1.193 -e 'show databases;'
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM