How to setup a remote MySQL connection?

Questions LEMP Stack Q & ACategory: LinuxHow to setup a remote MySQL connection?
lempstack asked 4 years ago

How to setup a remote MySQL connection?

1 Answers
lempstack answered 4 years ago
For security reasons, OneinStack only allows the cloud host localhost to connect to the database,if you need a remote connection to the database,the following operations are required: 1. You must open port 3306 for Security groups 2. Database authorization Remote Connection Create a new account(Account name can not be root)
E.g:add a user named db_user, password db_pass,Authorized as % (% Represents all ip can connect, you can set the designated ip)db_name database all authority, the commands are as follows # mysql  -uroot  -p MySQL [(none)]> grant all privileges on db_name.* to db_user@’%’ identified by ‘db_pass’;  # Authorization statement,Special attention to the semicolon MySQL [(none)]> flush privileges; MySQL [(none)]> exit;  # Quit the database console, Special attention to the semicolon As shown below:
点赞