欢迎光临
我们一直在努力

阿里云服务器 ——宝塔面板配置安装的数据库如何进行远程连接

首先在服务器安全组添加3306放行端口

继而再去面板中添加3306放行端口

在阿里云服务器中登录mysql进行远程配置(权限为root才能配置,否则配置不成功)

1. 先用localhost登录
# mysql -u root -p
Enter password
2. 执行授权命令
mysql> grant all privileges on *.* to root@'%' identified by 'password'; 红色底板的password自行设置
Query OK, 0 rows affected (0.07 sec)
3. 退出再试
mysql> quit
Bye
再试登录:(这里测试用另一台主机(我这里用win10的cmd命令行连接)就能登录,得先连网)

C:\Users\ASDS>mysql -uroot -h 主机ip -p     红色底板的主机ip是要连接的数据库的载体主机ip
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 39
Server version: 5.5.61-log Source distribution

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>

登录成功

第二种授权方式:

先在服务器数据库中创建一个用户和密码:

mysql> create user geek identified by 'password';
Query OK, 0 rows affected (0.00 sec)

执行授权连接单独的一个数据库,我这里连接test数据库:

mysql> grant all privileges on test.* to geek@'%';
Query OK, 0 rows affected (0.00 sec)

 登录测试

C:\Users\ASDS>mysql -ugeek -h 128.10.2.64 -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 40
Server version: 5.5.61-log Source distribution

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>

登录成功

  • 海报
海报图正在生成中...
赞(0) 打赏
声明:
1、本博客不从事任何主机及服务器租赁业务,不参与任何交易,也绝非中介。博客内容仅记录博主个人感兴趣的服务器测评结果及一些服务器相关的优惠活动,信息均摘自网络或来自服务商主动提供;所以对本博客提及的内容不作直接、间接、法定、约定的保证,博客内容也不具备任何参考价值及引导作用,访问者需自行甄别。
2、访问本博客请务必遵守有关互联网的相关法律、规定与规则;不能利用本博客所提及的内容从事任何违法、违规操作;否则造成的一切后果由访问者自行承担。
3、未成年人及不能独立承担法律责任的个人及群体请勿访问本博客。
4、一旦您访问本博客,即表示您已经知晓并接受了以上声明通告。
文章名称:《阿里云服务器 ——宝塔面板配置安装的数据库如何进行远程连接》
文章链接:https://www.456zj.com/4015.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址