In the source code of the Dudian Card Issuance System, to achieve database separation and remote database access, you can use the following method.

In the .env configuration file, modify the following code:

# Database configuration
DB_CONNECTION=mysql
DB_HOST=48.158.286.102
DB_PORT=3306
DB_DATABASE=test123
DB_USERNAME=test123
DB_PASSWORD=2MWAKx54cYCM9JTr

Ensure that the MySQL database on server 48.158.286.102 allows remote connections:

  • Check whether the MySQL configuration file (usually located at /etc/mysql/my.cnf or /etc/my.cnf) is bound to 0.0.0.0 (allowing access from all IPs).
  • Modify bind-address, add it if it does not exist.
bind-address = 0.0.0.0   You can also specify a specific IP

Restart the MySQL service.

Ensure that user test123 is granted access. Log in as the root user via a MySQL tool, find the corresponding database test123, and execute the following statement.
GRANT ALL PRIVILEGES ON test123.* TO 'test123'@'%' IDENTIFIED BY '2MWAKx54cYCM9JTr';
FLUSH PRIVILEGES;
Check whether the server firewall (e.g., UFW or iptables) allows access on port 3306, and add the database access port and the corresponding authorized IP address.

If the server has a security group, add access permissions for port 3306 in the server management settings.