登录  /  注册
Linux系统MySQL数据库远程设置
php中文网
发布: 2016-06-07 17:34:31
原创
601人浏览过

Linux系统MySQL数据库远程设置 1.启动服务和登陆 [root@localhost ~]# /etc/init.d/mysqld restart Stopping mysqld:

Linux系统MySQL数据库远程设置

1.启动服务和登陆
[root@localhost ~]# /etc/init.d/mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
[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.1.66 Source distribution
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>

2.授权一个可以远程登陆的用户
mysql> grant all privileges on *.* to tong@'%' identified by 'system'; --创建一个远程用户
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges; --更新权限
Query OK, 0 rows affected (0.00 sec)
mysql>

3.关闭防火墙
[root@localhost ~]# /etc/init.d/iptables stop
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
[root@localhost ~]#

4.用客户端工具可以登陆了
C:\Users\Administrator>mysql -h 远程IP -u tong -p --tong是远程用户名
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 32
Server version: 5.5.19 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>

错误处理:

(1)防火墙没有关闭或防火墙没有过滤3306端口

图:



解决方法:

[root@localhost ~]# /etc/init.d/iptables stop
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
[root@localhost ~]#

或者:

[root@localhost ~]# vim /etc/sysconfig/iptables --添加以下一行
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

(2)密码输入错误

图:



解决方法:输入正确的密码,如果密码忘记了在服务器系统里修改一下

Linux 下MySQL的安装和远程设置

linux

来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 技术文章
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2023 //m.sbmmt.com/ All Rights Reserved | 苏州跃动光标网络科技有限公司 | 苏ICP备2020058653号-1

 | 本站CDN由 数掘科技 提供

登录PHP中文网,和优秀的人一起学习!
全站2000+教程免费学