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

原文地址:https://www.cnblogs.com/clubs/p/9279468.html