如何设置mysql远程访问

本文介绍如何检查并启动远程主机上的MySQL服务,包括修改root用户的host权限、开启防火墙的3306端口及重启服务的方法。

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

1.查看远程主机mysql服务状态

1 [root@localhost ~]# service mysqld status
2 mysqld is stopped

2.启动远程机mysql服务

如mysql服务未启动, 则先启动mysql服务

[root@localhost ~]# /etc/init.d/mysqld start
Starting MySQL:                                            [  OK  ]

3.进入mysql

[root@localhost ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.45 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

4.选择mysql库名

1 mysql> use mysql;
2 Reading table information for completion of table and column names
3 You can turn off this feature to get a quicker startup with -A
4 
5 Database changed
6 mysql> 

5.将mysql库中, root用户的host由localhost改为%

mysql> UPDATE user SET Host='%' WHERE User='root';

6.打开防火墙的3306mysql默认端口, 可参照http://www.cnblogs.com/leaf1117/p/3461952.html              

         
7.重启服务

转载于:https://www.cnblogs.com/leaf1117/p/3461958.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值