码迷,mamicode.com
首页 > 数据库 > 详细

mysql远程登录问题

时间:2016-09-09 09:59:31      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:

 [Q1] 解决mysql远程登录

一、确认服务器端口号开放
1、确认3306端口是否对外开放

ubuntu@ubuntu:~$ netstat -an | grep 3306
tcp0 0 127.0.0.1:3306  0.0.0.0:*   LISTEN


此处3306端口只监听本地的(127.0.0.1)连接,修改/etc/mysql/my.cnf中的bind-address,注释掉或者改成指定的IP
二、授权远程连接用户<br>
1、登录:

mysql -uroot -pxxxx

2、授权

grant all privilege on [database].[table] to [user]@[ip] identified by [password]
mysql>grant all on *.* to user_name@‘%‘ identified by ‘user_password‘;

database:授权的数据库名,所有的数据库用匹配符`*`<br>
table:授权的表名,所有的表用匹配符`*`<br>
user:授权的用户名<br>
ip:授权的ip地址,例如 xxx.xxx.xxx.xxx 

password:授权用户名的密码,例如 xxxxxx 
3、刷新授权或者mysql重启

flush privilege
sudo /etc/init.d/mysql restart

---
[Q2]mysql 命令导入csv

select * from test_info   
into outfile /tmp/test.csv   
fields terminated by , optionally enclosed by " escaped by "   
lines terminated by \r\n; 

 

mysql远程登录问题

标签:

原文地址:http://www.cnblogs.com/datasnail/p/5855228.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!