Why is 'localhost' the default host used when trying to connect to MariaDB?

why is the sky blue
why is the sky red
why is the sky blue and sunsets red
why is the sun yellow
why is the sky blue for kids?
why is the sea blue
why is the sky blue and not violet
why is the sky pink

I have recently installed MariaDB on Fedora 19 in VirtualBox on Windows 7.

When I run:

MariaDB [(none)]> SELECT user, host, password FROM mysql.user;

I get:

+------+----------------------+-------------------------------------------+
| user | host                 | password                                  |
+------+----------------------+-------------------------------------------+
| root | localhost            | ***************************************** |
| root | my.hostname          | ***************************************** |
| root | 127.0.0.1            | ***************************************** |
| nusr | my.hostname          | ***************************************** |
+------+----------------------+-------------------------------------------+

my.hostname is the hostname I changed the default hostname to in Fedora.

I created the user 'nusr' with:

CREATE USER 'nusr'@'my.hostname' IDENTIFIED BY 'my_password';

When I try and connect to MariaDB with:

[me@my ~]$ mysql -u nusr -p
Enter password: 

I get:

ERROR 1045 (28000): Access denied for user 'nusr'@'localhost' (using password: YES)

I am guessing this is because it is referring to 'nusr'@'localhost' instead of 'nusr'@'my.hostname'.

Why is 'localhost' the default host used when trying to connect to MariaDB?

Do the host's 'localhost' and '127.0.0.1' need to be kept?

As a context to this question, I am not really sure what the terms 'host' and 'hostname' mean, I just wanted to 'customise' my experience of learning MariaDB commands, so perhaps I have gone awry by completing the steps above.


Very old question but..

ERROR 1045 (28000): Access denied for user 'nusr'@'localhost' (using password: YES)

I am guessing this is because it is referring to 'nusr'@'localhost' instead of 'nusr'@'my.hostname'.

YES.

Why is 'localhost' the default host used when trying to connect to MariaDB?

Because the assumption is that you will connect to the database from the same machine the database is in (localhost).

If you define the user as being @my.hostname it means the connection to the database will be made from another machine, called my.hostname.

Do the host's 'localhost' and '127.0.0.1' need to be kept?

Only if you want to be able to access the database from there.. In that setup, if you delete root user @localhost and @127.0.0.1 then you will not be able to log into the database from inside the virtualbox where the database resides. And you will only be able to access if you connect from a machine called my.hostname. But for that to work you must make sure that the database environment knows my.hostname.

Why is Cats?, Why is the sky blue? The sky appears blue to the human eye as the short waves of blue light are scattered more than the other colours in  noun, plural whys. a question concerning the cause or reason for which something is done, achieved, etc.: a child's unending hows and whys. the cause or reason: the whys and wherefores of a troublesome situation. interjection. (used as an expression of surprise, hesitation, etc., or sometimes a mere expletive): Why, it's all gone!


The MariaDB server (also MySQL) treats localhost in a special way. Where other software treat it like an alias of the loopback address 127.0.0.1, MariaDB will interpret it as a UNIX domain socket connection to the server. By default this socket file is located in /var/lib/mysql/mysql.sock.

To connect via the network to the local server, use the -h 127.0.01 parameter. This tells the mysql client to connect via the loopback network interface instead of the socket.

Regardless of other grants, MariaDB will always translate localhost to a local socket connection. If you want to prevent this and only allow access via the network, drop the users that have localhost as their host.

You can view all users in the database by executing the following query:

SELECT * FROM mysql.user

Why is there Land?, Whether it's a t-shirt made of ethical cotton, or an 'eco' car - companies are increasingly keen to showcase their green credentials. On the surface,  Noun. 1. why - the cause or intention underlying an action or situation, especially in the phrase `the whys and wherefores'. wherefore. reason, ground - a rational motive for a belief or action; "the reason that war was declared"; "the grounds for their declaration".


You must create properly user on system Fedora 19:

[root@localhost ~]# useradd nusr 
[root@localhost ~]# passwd nusr 
Changing password for user fedora.
New UNIX password:# set password
Retype new UNIX password:# confirm
passwd: all authentication tokens updated successfully.
[root@localhost ~]# exit # logout

So, a database didn't find user nusr and it will not to handle user nusr because isn't created on system wide.

Hostname is from IP address named as "mydomain.com", but "host" can be IP address or name lookup host "mydomain.com".

Why Is the Sky Blue?, Are you learning new vocabulary? Or do you just have an interest in words? Either way, this quiz is for you. Question 1 of 10. orchard. noun, plural whys. a question concerning the cause or reason for which something is done, achieved, etc.: a child's unending hows and whys. the cause or reason: the whys and wherefores of a troublesome situation. interjection. (used as an expression of surprise, hesitation, etc., or sometimes a mere expletive): Why, it's all gone!


Why is the sky blue?, To figure out what makes some people more vulnerable to severe cases of covid-​19, we need to rethink what we know about infection. A difficult problem or question. Used to express mild surprise, indignation, or impatience. [Middle English, from Old English hwȳ; see k w o- in Indo-European roots .] Usage Note: A traditional rule states that why is redundant in the expression reason why, as in The reason why he accepted the nomination is not clear.


What is greenwashing and why is it a problem?, Why is the disease being called coronavirus disease 2019, COVID-19? Can the virus that causes COVID-19 be spread through food,  27 synonyms of why from the Merriam-Webster Thesaurus, plus 39 related words, definitions, and antonyms. Find another word for why. Why: how surprising, doubtful, or unbelievable.


Terry Moore: Why is 'x' the unknown?, The question: "Why is [etc.]" is a question form in English: Why is the sky blue? Why is it that children require so much attention? Why is it [or some thing] like that? When that form is put into what is called indirect speech, it becomes: Please tell me why the sky is blue. Please tell me why children require so much attention.