Laravel permission denied on remote Mysql server (AWS aurora)

前端 未结 2 1051
盖世英雄少女心
盖世英雄少女心 2021-01-04 19:21

I have a centos EC2 with Laravel application. I also have MySQL installed on the same EC2 instance. It was working fine.

Now I decieded to move MYSQL to AWS RDS (MyS

相关标签:
2条回答
  • 2021-01-04 20:02

    If you are running SELinux on your centos EC2, try switching off SELinux and test your application again. If it's SELinux that's causing this problem, it might well be because of the policy for external connection to database. You should switch SELinux back ON and enable the policy with this command.

    sudo setsebool -P httpd_can_network_connect_db=1
    
    0 讨论(0)
  • 2021-01-04 20:10

    Edit your /etc/my.cnt like this:

    bind-address = 0.0.0.0 # will accept requests from all IPs
    

    Then in your mysql add a user and give him the proper permissions

    grant all privileges on db_name.* to 'username'@'%' identified by 'password';
    

    This enables the user to connect to the database from any IP

    grant all privileges on db_name.* to 'username'@'your_ip' identified by 'password';
    

    This enables the user to connect to the database from only one IP. This is the best practice, you don't want to allow connections from any IP, this is a bad security practice.

    This will enable you to connect to the database from your external IP

    Why your RDB instance is not working is not totaly clear, have you enabled remote connections?

    0 讨论(0)
提交回复
热议问题