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