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的安装和远程设置
,