3.5 linux系统mysql实现外部链接

1.安装mysql服务

//配置mysql的yum源
[root@yusyang src]# wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
[root@yusyang src]# yum -y install mysql57-community-release-el7-10.noarch.rpm

//安装mysql5.7 
[root@yusyang src]# yum -y install mysql-community-server mysql-community-client mysql-community-common mysql-community-devel

//为避免mysql自动升级,这里需要卸载最开始安装的yum源
[root@yusyang ~]# rpm -qa|grep mysql
mysql-community-server-5.7.23-1.el7.x86_64
mysql57-community-release-el7-10.noarch
mysql-community-common-5.7.23-1.el7.x86_64
mysql-community-client-5.7.23-1.el7.x86_64
mysql-community-libs-compat-5.7.23-1.el7.x86_64
mysql-community-libs-5.7.23-1.el7.x86_64
mysql-community-devel-5.7.23-1.el7.x86_64
[root@yusyang ~]# yum -y remove mysql57-community-release-el7-10.noarch

2.修改mysql登录密码

//启动mysql服务
[root@yusyang src]# systemctl start mysqld

//查看3306端口是否被启用
[root@yusyang ~]# ss -anlt
State      Recv-Q Send-Q         Local Address:Port                        Peer Address:Port              
LISTEN     0      128                        *:111                                    *:*                  
LISTEN     0      128                        *:22                                     *:*                  
LISTEN     0      100                127.0.0.1:25                                     *:*                  
LISTEN     0      25                         *:514                                    *:*                  
LISTEN     0      128                       :::111                                   :::*                  
LISTEN     0      128                       :::22                                    :::*                  
LISTEN     0      100                      ::1:25                                    :::*                  
LISTEN     0      25                        :::514                                   :::*                  
LISTEN     0      80                        :::3306                                  :::*

//查看初始密码
[root@yusyang ~]# grep "password" /var/log/mysqld.log
2019-11-16T02:06:09.474306Z 1 [Note] A temporary password is generated for root@localhost: 3aJ-Q+iQakZb

//使用初始密码登录mysql
[root@yusyang ~]# mysql -uroot -p'3aJ-Q+iQakZb'
mysql>

//修改登录密码
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)

mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)

mysql> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye

//使用修改后的密码登录
[root@yusyang ~]# mysql -uroot -p123456
mysql>

3.授权root用户可以在192.168.80.1远程登录

mysql> grant all on *.* to 'root'@'192.168.80.1' identified by '123456';

4.使用Navicat for MySQL远程连接IP为192.168.80.128的数据库

在这里插入图片描述

  • 创建数据库db_new并新建表user
    在这里插入图片描述
  • 查看创建数据库db_new表user
mysql> use db_new
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> select * from user;
+----+------+----------+
| id | user | password |
+----+------+----------+
|  1 | root | 123456   |
|  2 | tom  | 12345678 |
+----+------+----------+
2 rows in set (0.00 sec)
发布了50 篇原创文章 · 获赞 8 · 访问量 1891

猜你喜欢

转载自blog.csdn.net/Yusyang_/article/details/103096746
3.5