问题描述
我刚刚在mysql服务器上启用了远程访问.我通过转到数据库'mysql',然后是user表并将Host列更改为适当用户的'%'来完成此操作.完成此操作后,我注意到我无法在本地访问它,即,当我通过SHELL登录到服务器时,我无法登录.
是否既可以同时进行本地访问又可以进行远程访问?
您需要在mysql.user
表中具有host
值为'localhost'的单独行,以启用本地unix套接字类型连接. /p>
host
列中的'%'
值适用于TCP协议.
此处的文档详细信息: http://dev.mysql. com/doc/refman/5.5/en/connecting.html
我在mysql.user
表中为用户提供了三行,其中host
的值为'localhost'
(用于unix套接字类型的连接),'127.0.0.1'
的值为从本地主机通过TCP访问,而'%'
用于从其他主机进行TCP访问.
请注意,MySQL不仅将用户标识为用户名",而且还将其标识为用户名"和主机"的组合.这些用户被视为不同的用户,并且每个用户可以具有不同的密码和不同的特权集.
I just enabled remote access on my mysql server.I did this by going to the database 'mysql' , then the user table and changing the Host column to '%' of the appropriate user. After doing this I noticed that I can't access it locally i.e. when I'm logged into the server via the SHELL, I can't login.
Is it not possible to have both local and remote access ?
You need to have a separate row in the mysql.user
table with a host
value of 'localhost', to enable local unix socket type connections.
A value of '%'
in the host
column is for the TCP protocol.
Details in the documentation here: http://dev.mysql.com/doc/refman/5.5/en/connecting.html
I have three rows for a user in the mysql.user
table, with host
values of 'localhost'
(for unix socket type connections), '127.0.0.1'
for access via TCP from the local host, and '%'
for TCP access from other hosts.
Note that MySQL identifies a user not just by the "username", but as the combination of "username" and "host". These are considered distinct users, and each of them can have a different password and a different set of privileges.
这篇关于MySQL启用远程和本地访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!