Remote connect to mysql database

本文详细介绍了如何在Windows和Linux环境下配置MySQL服务器,以便从远程客户端进行连接。主要内容包括修改MySQL用户表设置允许远程访问、授予特定IP地址权限以及调整配置文件等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. mysql server installed on windows
if you want to connect the mysql server from the remote windows cliect,
you need to modify the user table of mysql database in mysql server, as follow:
update user set host = '%' where user = 'root';
or
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;(Note: password is root user's password)

if you want to connect to mysql server from a bind machine, you can execute the command:
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.8' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
so you can connect to mysql server from the 192.168.1.8 machine.

grant definition: grant rights on database's object to user
localhost: express you can login mysql server from localhost
%: express you can login from any machine in your network

2. mysql server installed on linux
if you want to connect the mysql server from the remote windows client, please follow the 1 step above.
if you can't login yet, you can modify the /etc/mysql/my.cnf file, remove or comment the "bind-address = 127.0.0.1" sentence,
this sentence express the mysql server only listen to the localhost machine.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值