Many of you have contacted me asking me how to create a basic wp-config in your WordPress because in your hosting, instead appears the wp-config-sample. In this article I'm going to explain in simple words how to do it.
Content of this Article
¿Qué es el wp-config?
As you probably already know, WordPress works through programmed files and a parallel database, where most of the information and content of your website is stored.
In order for WordPress to query the database, you need to know the access data and the tables where you need to look for the information.
The wp-config.php file is stored in the root directory of your hosting and is the one that contains that access information. If this file does not have the correct information, when trying to access your website, you will get an error saying that WordPress cannot connect to the database.
In some cases, especially when you contract a hosting with WordPress pre-installed and do not modify any parameters later, this file is called wp-config-sample.php.
For security reasons, the correct thing to do is to replace this file with one with the standard configuration and call it by its name.
How to create a basic wp-config?
The operation of this tool is very simple:
- Fill in the fields of each section.
- Generates the file wp-config.php.
- Download it to your computer.
- Upload it to your hosting.
- Delete wp-config-sample.php
In addition, the good thing is that it already has the basic settings by default so you only have to fill in the first two sections:
- Database connection.
- Database tables.
Important! To locate the data that you have to put in each field, you need to have access to the Control Panel of your hosting.
All the data they ask for here, you already appeared when you installed WordPress for the first time, but as you may not remember them, let's see where to retrieve them.
To locate this data: Go to your CPanel and look for an icon or option called "MySQL Databases". You will open a new screen and here you will be locating these data
- Name of the database: you have it right on the new screen, in the section "Current databases". Copy and paste.
- User name: you have it in the same row as the previous data, right in the column that says "user with privileges". Copy and paste.
- Password: if you don't remember it, you have to go to the database screen and search where it says "current users". Search the table for the user you entered in step 2 and click to the right where it says "change password". Put her herself in field 3.
In fields 4, 5 and 6 do not modify anything. Leave the data that comes by default.
Once the first part of the form has been filled in, we move on to the part where the information relating to the database tables appears. This will also need to be revised to create a basic wp-config.
You must pay special attention to the first two fields and look for the information you have in your database to fill them in correctly.
To find the data, go to CPanel > PHPMyAdmin and display the tables corresponding to the installation.
Locates the table corresponding to the users, normally it will have the name "users".
This name consists of two words separated by an underscore (_).
In field 1, fill in the first word, which will be the database prefix
In field 2, enter the second word, which will be the name of the users' table.
Generate and download
Once you have completed the options explained so far, you can create a wp-config with the basic configuration. To do this, you have to click on the "Generate" button.
The next step is to download it to your computer, for which you must click on the "Generate" button.
Upload to your server
Y para finalizar, bastará con subir el fichero generado, mediante FTPFTP Protocolo de internet utilizado para transferir archivos a de un ordenador a otro o, en el caso de WordPress, de un ordenador a un servidor. o el administrador de archivos de CPanel hasta tu servidor.
This file has to go in the root directory of the installation, out of any other folder.
Remember to delete the wp-config-sample file later, if you have it, using the same method you used to upload the new file.
As you can see, it is very easy to create a basic wp-config with the necessary adjustments to repair errors in the connection of the files with the database.
Simply access the tool to generate wp-config and follow the steps explained in this article.
Was it useful? Did you have to create the file because of an error? Could you solve it?
Leave us your comment below and share your experience with other users.
Implementer and Trainer specialized in WordPress,
Co-organizer of the group Meetup WordPress Madrid.
Collaborator in the translation team of WordPress Spain.
Podcaster, YouTuber and founder of the blog WPnovatos.com