Web lists-archives.com

Re: Re: how to force mysql to use the name of my machine instead of localhost




Abdelkader Belahcene wrote:

> *Thanks for reply and links*
> 
> 
> *But I am sure, the problem is in mysql.*
> *Look at this: *
> 
> *my count is lite@lite*
> *and hostname  gives *
> *lite@lite:/opt/lampp$ hostname*
> *lite.umbb.dz <http://lite.umbb.dz>*
> 
> 
> *bin/mysql*
> 
> *ERROR 1045 (28000): Acces s denied for user 'lite'@'localhost' (using
> password: YES)*
> 
> *Here it tries to connect as 'lite'@'localhost', I am
> not  'lite'@'localhost', but lite@lite*
> *then  same thing as root, even if use -h option : *
> 
> *lite@lite:/opt/lampp$ bin/mysql -u root -h lite*
> *ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using
> password: YES)*
> *I tried  again, using the complete name, it adds localhost!!!!*
> 
> *lite@lite:/opt/lampp$ bin/mysql -u root@xxxxxxxxxxxx <root@xxxxxxxxxxxx>
> -p*
> *Enter password: *
> *ERROR 1045 (28000): Access denied for user 'root@xxxxxxxxxxxx
> <root@xxxxxxxxxxxx>'@'localhost' (using password: YES)*
> *Thanks a lot*

There is a difference between using localhost and 127.0.0.1 (AFAIR).
Using localhost enforces using unix socket and not interface (tcp)
connection (AFAIR)

It all depends on giving the right permissions to your user. I think giving
root permissions to external interface is discouraged.
Having said that, what you need to do is give permission to the user to
connect properly

GRANT ALL PRIVILEGES ON <database name>* to '<user name>'@'127.0.0.1'
identified by  '<user password>';

bin/mysql -u <user name> -p -h 127.0.0.1 <database name>

GRANT ALL PRIVILEGES ON <database name>* to '<user name>'@'lite.umbb.dz'
identified by  '<user password>';

bin/mysql -u <user name> -p -h lite.umbb.dz <database name>

it's not exactly rocket science

regards