VMware虛擬機里centos7下安裝mysql5.6並授權遠程連接Navicat


這節來安裝Mysql5.6,並遠程授權連接本地windows的Navicat,可以根據以下步驟安裝。此文章為自己收藏,必要時拿出來直接用的,有需要的友友可以查看查看的。文章圖片有借助於網絡的。

1.新開的雲服務器,需要檢測系統是否自帶安裝mysql

# yum list installed | grep mysql

2.如果發現有系統自帶mysql,果斷這么干

# yum -y remove mysql-libs.x86_64

3.隨便在你存放文件的目錄下執行,這里解釋一下,由於這個mysql的yum源服務器在國外,所以下載速度會比較慢,還好mysql5.6只有79M大,而mysql5.7就有182M了,所以這是我不想安裝mysql5.7的原因

# wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm

4.接着執行這句,解釋一下,這個rpm還不是mysql的安裝文件,只是兩個yum源文件,執行后,在/etc/yum.repos.d/ 這個目錄下多出mysql-community-source.repo和mysql-community.repo

# rpm -ivh mysql-community-release-el6-5.noarch.rpm

5.這個時候,可以用yum repolist mysql這個命令查看一下是否已經有mysql可安裝文件

#yum repolist all | grep mysql

6.安裝mysql 服務器命令(一路yes):

# yum install mysql-community-server

7.安裝成功后

# service mysqld start

8.由於mysql剛剛安裝完的時候,mysql的root用戶的密碼默認是空的,所以我們需要及時用mysql的root用戶登錄(第一次回車鍵,不用輸入密碼),並修改密碼

# mysql -u root
# use mysql;
# update user set password=PASSWORD("這里輸入root用戶密碼") where User='root';
# flush privileges; 

9.查看mysql是否自啟動,並且設置開啟自啟動命令

# chkconfig --list | grep mysqld# chkconfig mysqld on

10.mysql安全設置(系統會一路問你幾個問題,看不懂復制之后翻譯,基本上一路yes):

# mysql_secure_installation

以下是講解授權遠程登錄,以Navicat工具為主

授權遠程訪問:

登陸:

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

Copyright (c) 2000, 2018, 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| fgf |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.00 sec)

mysql>

使用mysql數據庫(真正的數據庫,而非數據庫軟件),將所有數據庫的所有表(*.*)的所有權限(all privileges),授予通過任何ip(%)訪問的root用戶,密碼為123456,最后刷新(flush privileges)即可。

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> grant all privileges on *.* to 'root'@'%' identified by 'root';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql>

開放防火牆端口:

新開終端窗口,通過vim修改/etc/sysconfig/iptables,添加一行(這里是為了簡單添加一行,更多防火牆知識請自行學習):

[root@localhost /]# cd /
[root@localhost /]# vim /etc/sysconfig/iptables

-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT

重啟防火牆:

[root@localhost /]# service iptables restart
iptables:應用防火牆規則:iptables-restore: line 1 failed
[失敗]
[root@localhost /]#

注意:我本地虛擬機防撞牆關掉了,所以重啟防火牆的時候報錯,關掉防火牆不影響mysql授權遠程連接Navicat

在windows下,我用 navicat測試:

遠程連接成功。

因為我本地虛擬機已裝有MySQL,所以我是直接跳過MySQL安裝這一步,直接進行授權遠程登錄步驟,結果用Navicat測試可以成功連接

文章轉載:https://mp.weixin.qq.com/s/hekiOAFDd5TvV_2_ztbZLw


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM