Wherever data is being stored on a computer, this computer is referred to as a “host.” Effectively, “localhost” means your personal computer, i.e. the same one that is running the browser software.
A URL or website address that you type into your browser is for when you want to connect to a network host (a different computer) via the internet. But if you type “localhost” into your browser, you will then start browsing your own computer.
If you’re new to WordPress, then you won’t ever have to worry about what “localhost” is used for. But if you’re a developer, “localhost” is for testing an installation of a WordPress site that is hosted on your own computer. Therefore, instead of typing in a URL to access a different computer on the internet, “localhost” tells your browser that the website is located on your own computer.
Installing, customizing, and testing a WordPress site that is running on your own computer is a really powerful tool for making sure that everything is working the way you want it to before transferring the files to a web host. Because there’s no lag or delay in communicating across the internet, a local installation is often the preferred first step for professional developers.
Another use for “localhost” is for when your WordPress site needs to be connected to a MySQL database during the installation process. If you’re not sure what to do, always contact your web host in order to install WordPress properly and ensure that it connects to the MySQL database.
Most of the time, however, the MySQL database and your WordPress files will be stored on the same (web host) computer. Therefore, MySQL’s “address” is localhost because it is the same location as where the WordPress files are stored even though neither is on your personal computer.