Friday, March 8, 2013

Connection with MYSQL from a remote machine

1. Connection with root user
     cmd> mysql -p -u root -h ip_of_the_machine


2. receive the error:
ERROR 1044 (42000): Access denied for user 'root'@'%' to database ' 

enviornment:->
mysql is installed on 192.168.1.10
need to connect from  192.168.1.20

command execute on "192.168.1.10"

create database remote;




--chose any one pattern from below(i worked with second)
CREATE USER 'g'@'%' IDENTIFIED BY 'g';
CREATE USER 'g'@'localhost' IDENTIFIED BY 'g';
CREATE USER 'g'@'192.168.1.20' IDENTIFIED BY 'g';

grant all on *.* to g@'%';
grant all on *.* to g@'localhost';
grant all on *.* to g@'192.168.1.20';

grant all on database_name.* to g@'localhost';

update mysql.db set host='192.168.1.20' where db='g';
UPDATE mysql.USER SET Host='192.168.1.20' WHERE USER='g';


--RESTART THE services for MYSQL

command execute on "192.168.1.20"
cmd> mysql -p  -u l -h 192.168.1.10
mysql> select current_user(); 


:::::::::::::::::::::::::::::::::::::::::::::::: W O R K I N G ::::::::::::::::::::::::::::::::::::::::::::::::::

No comments:

Post a Comment

web stats