Reputation: 3464
I'm using hostinger's Single Shared Hosting for my website.
I have created a MySQL database and I need to have access to username and password in my PHP api endpoints. So, I created a /config.php
file with -rw-r--r--
permissions:
<?php
define("dbHost", "localhost");
define("dbUsername", "XXXXXXXXX");
define("dbPassword", "XXXXXXXXX");
?>
Is it a good way of storing such information?
Upvotes: 0
Views: 156
Reputation: 166
You can't start without making a config file. But you can encrypt the data of your database. Below are a few simple steps to encrypt your data in MySQL 8.0. This process relies on a keyring file. This won’t meet compliance requirements (see KEY MANAGEMENT SYSTEMS below), but it’s a good first step.
early-plugin-load = keyring_file.so
Execute the following queries:
INSTALL PLUGIN keyring_udf SONAME ‘keyring_udf.so’;
CREATE FUNCTION keyring_key_generate RETURNS INTEGER SONAME ‘keyring_udf.so’;
SELECT keyring_key_generate(‘alongpassword’, ‘DSA’, 256);
ALTER TABLE titles ENCRYPTION = ‘Y’;
Per documentation warning: The keyring_file and keyring_encrypted file plugins are not intended as regulatory compliance solutions. Security standards such as PCI, FIPS, and others require use of key management systems to secure, manage, and protect encryption keys in key vaults or hardware security modules (HSMs).
I hope this article will work for you.
Upvotes: 1