当前位置:网站首页>Reasons why MySQL cannot be connected externally after installing MySQL database on ECs and Solutions

Reasons why MySQL cannot be connected externally after installing MySQL database on ECs and Solutions

2022-06-25 22:29:00 Want none

When using the bird cloud server to build a website , Because of the installation mysql There are some problems in the process of teaching , So I'm going to write it down , The first one is about installation mysql after , But can't be accessed from the outside , And how to solve it , In addition to searching for relevant information by yourself , You can also consult the corresponding technicians , The response soon , The problem can also be solved .
Return to the right topic .
mysql Only local connections are allowed by default , in other words , After installation mysql There will be two after root Account , their host Namely localhost and 127.0.0.1, If your website and database are on the same server , So it's accessible . But if your website and database are not on different servers , Then the website won't be able to use remote databases ( The database server denied access to ).
1. Change table
Sign in phpmyadmin, Put the user's host Modified into %, Restart the server .
use mysql;
update user set host='%' where user='root'
flush privileges;
2. to grant authorization
Such as : Allow account myuser Use password 1234 Connect from any host to mysql Server , Then in mySQL Type... On the command line :
GRANT ALL PRIVILEGES ON . TO 'myuser'@'%' IDENTIFIED BY '1234' WITH GRANT OPTION;
here % To allow all IP Address access . It can be changed to specific IP, such as :
Allow account myuser from ip by 192.168.1.3 Of hosts connected to mysql The server , And use 12345 As password , Then in mySQL Type... On the command line :
GRANT ALL PRIVILEGES ON . TO 'myuser'@'192.168.1.3' IDENTIFIED BY '12345' WITH GRANT OPTION
Last , Make Settings work
mysql>FLUSH PRIVILEGES
Refer to this document for specific settings :https://www.niaoyun.com/docs/...

原网站

版权声明
本文为[Want none]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202181043145587.html