当前位置:Gxlcms > 数据库问题 > 阿里云服务器 ——宝塔面板配置安装的数据库如何进行远程连接

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

时间:2021-07-01 10:21:17 帮助过:13人阅读


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>

登录成功

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

标签:word   copy   ade   服务器安全   ***   spec   moni   远程连接   ted   

人气教程排行