MySQL的远程访问 [英] Remote Access fot MySQL

查看:57
本文介绍了MySQL的远程访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想远程连接MySQL数据库,但是我不能,该怎么办?

我已经这样尝试过:
C:> CD程序文件MySQLMySQL Server 4.1bin"

请记住,根据您安装MySQL的方式,您的目录结构可能与我的不同.另外,您可能需要做一些清除目录"(即"CD"或CD ..)才能到达C:>的基数.
输入:

mysql -u root -p

并在出现提示时输入您的root密码.
如果成功登录,则应该看到:

mysql>

如果没有,您将得到类似以下内容的信息:

错误1045(28000):用户``blah''@``localhost''的访问被拒绝(使用密码:是)

输入

*.*将所有特权授予``PASSWORD''标识的``USERNAME''@@``IP'';

这将创建一个具有ROOT权限的新用户,因此请务必小心要创建的帐户.如果您仅使用root帐户,则将USERNAME替换为root.正是这样,我们很清楚,USERNAME是您要创建或使用的帐户. IP是您希望授予远程访问权限的计算机的物理IP地址.如果您输入%"而不是IP地址,则该用户将能够从任何计算机上远程访问MySQL服务器.如果是新用户或现有帐户的现有密码,则PASSWORD是您希望创建的密码.是的,您需要使用单引号.
最后,您要运行最后一条命令:

mysql>冲洗特权;

要退出,只需键入:

I want to connect mySql Database Remotely.But I cant.How can I do that?

I have tried like this:
C:>CD "Program FilesMySQLMySQL Server 4.1bin"

Keep in mind that your directory structure might differ from mine depending on how you installed MySQL. Also you may have to do a few "Clear Directories" (i.e. "CD" or CD..) to get to the base of C:>.
Type in:

mysql -u root -p

and enter in your root password when prompted.
If you logged in successfully, you should see:

mysql>

and if not, then you will get something like:

ERROR 1045 (28000): Access denied for user ''blah''@''localhost'' (using password: YES)

Enter in

GRANT ALL PRIVILEGES ON *.* TO ''USERNAME''@''IP'' IDENTIFIED BY ''PASSWORD'';

What this will do is create a new user with ROOT privileges, so be very careful what account you are creating. If you are just using the root account, then replace USERNAME with root. And just so we are clear, USERNAME is the account you wish to create or use. IP is the physical IP address of the computer you wish to grant remote access to. If you enter ‘%’ instead of an IP number, that user will be able to remote access the MySQL server from any computer. PASSWORD is the password you wish to create if it’s a new user or the existing password of an existing account. And yes, you need to use the single quotation.
And finally, you want to run this last command:

mysql> FLUSH PRIVILEGES;

To exit, just type:

mysql> quit;





但还是不能.请给我解决方案.





but still I cant.Please give me solution.

推荐答案

您需要检查几件事.

如果数据库引擎与客户端在同一台计算机上运行,​​则必须授予''user''@''localhost''
特权
如果它是真正的远程连接(与db一样在其他主机上的客户端),则必须仅向用户"授予特权.

show grants命令将其显示为''user''@''%''.

您还必须检查my.cnf配置文件.如果要允许通过所有接口的远程连接或使用bind-address = <your server IP>指定NIC,请查找行bind-address = 127.0.0.1并对其进行注释.


问候
Michel
There are several things you have to check.

If your DB engine is running on the same machine as your client does, you have to grant privileges to ''user''@''localhost''

If it''s a real remote connection (client on other host as db is) you have to grant privileges just to ''user''.

The show grants command will show this as ''user''@''%''.

You also have to check the my.cnf config file. Look for line bind-address = 127.0.0.1 and comment it if you want to allow remote connections through all interfaces or use bind-address = <your server IP> to specify NIC.


regards
Michel


简便方法
下载mysql-workbench-gpl-5.2.38-win32版本
并安装

1)点击新连接,并给远程IP和db用户名
使用输入密码连接

您将获得远程访问权限...:)
Easy way
download mysql-workbench-gpl-5.2.38-win32 version
and install it

1)click on new connection and give the remote ip and db user name
connect with enter password

u will get the remote access ... :)


这篇关于MySQL的远程访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆