Macrotone Blogs

Macrotone blogs upon Joomla, our products and other matters.
Font size: +

Changing Joomla MySQL database connection details

mysqlWe recently had cause to have to modify the connection details that a Test Joomla setup was using to connect to the underlying database.  The reason was that we wanted to test out a component installation where some specific database privileges had not been granted.

In out case we were interested in the database privileges ‘CREATE VIEW’, ‘CREATE ROUTINE’ and ‘TRIGGER’. Since our component would make use of database triggers, procedures and views we needed to test out an installation on a system where such grants were not present.

Our systems had the required privileges granted and we knew that editing the ‘configuration.php’ file in the existing Joomla installation should enable us to achieve this easily, but despite our attempts this wouldn’t work and instead gave us an error: ‘Database connection error (3): Could not connect to database ‘.

We played with the username and password settings in the ‘configuration.php’ file without any success it just wouldn’t connect and we knew that we had another database set up with the same username and password.

Then we remembered that we had only granted permissions for this ‘restricted’ database account to a specific database.  All we had to do was ensure that the correct grants were made for our 'second database’.

   1:  CREATE USER 'test'@'localhost' IDENTIFIED BY 'password';           -- Not required if the user already exists.
   2:  GRANT SELECT, INSERT, UPDATE, DELETE ON DBX.* TO 'test'@'localhost';
   3:  CREATE USER 'test'@'%' IDENTIFIED BY 'password';                    -- Not required if the user already exists.
   4:  GRANT SELECT, INSERT, UPDATE, DELETE ON DBX.* TO 'test'@'%';
   5:   
   6:  GRANT LOCK TABLES, CREATE TEMPORARY TABLES, CREATE, DROP, INDEX, ALTER ON DBX.* TO 'test'@'localhost';
   7:  GRANT LOCK TABLES, CREATE TEMPORARY TABLES, CREATE, DROP, INDEX, ALTER ON DBX.* TO 'test'@'%';

 

Where test is the name of your connection user, password is whatever your desired password is, and DBX is the name of your MySQL database.  Obviously if your database is not on your localhost you need to modify it for the appropriate host name or IP address, which ever is most apt.

Once we had done this it all worked perfectly and our testing could commence.

Using an IDE for Joomla development
A new Audit tool for Joomla
 
Go To Top

Joomla! Debug Console

Session

Profile Information

Memory Usage

Database Queries