简体   繁体   中英

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?

You need to give permissions to connect from remotehost

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

This is connecting to the intended host as you require it to. t is just stating who is connecting. and where from.

USER@DOMAIN

user : your user running the mysql command domain : name of the system you are connecting from.

Log into mysql via the server using -u root, ensure the user 'domico' is created and has sufficient access.

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

通过 mysql 服务器创建一个新用户并授予它特权,您可以通过命令和使用任何服务器(例如使用工作台)来完成

For all users and all host.

mysql -u root -p

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

FLUSH PRIVILEGES;

QUIT;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM