Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect to MySQL Database on Local Network

I actually thought I could do this until I tried. I installed MySQL server on one PC in the Local network IP Address (192.168.1.4) and now I am trying to access it from another PC in the same network (192.168.1.5) but I am unable:

C:\Users\DOMICO>mysql -u domico -h 192.168.1.4 -p
Enter password: **********
ERROR 1045 (28000): Access denied for user 'domico'@'DOMICO-PC' (using password:
 YES)

Surprisingly DOMICO-PC is the PC I am trying to connect from. Why is it not connecting to the given host but trying to connect to Local machine?

like image 202
Stanley Mungai Avatar asked Jan 09 '23 09:01

Stanley Mungai


2 Answers

You need to give permissions to connect from remotehost

mysql>GRANT ALL PRIVILEGES ON database.* TO 'username'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;

like image 69
Vinoth Ramamoorthy Avatar answered Jan 17 '23 00:01

Vinoth Ramamoorthy


You need to have proper permissions to connect. In the computer that has the DB installed, give your user the proper permissions:

mysql>GRANT ALL PRIVILEGES ON *.* TO 'domico'@'DOMICO-PC';
mysql>FLUSH PRIVILEGES;

You can read more here: https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql

And here: https://dev.mysql.com/doc/refman/5.1/en/privileges-provided.html

like image 44
Tom Avatar answered Jan 17 '23 00:01

Tom