mysql 访问被拒绝,ssh 数据库主机
我正在尝试访问 mysql 到远程服务器,并在那里创建一个数据库。 我正在使用腻子进行连接。问题是我收到“访问被拒绝”错误 无论我做什么:
:mysql -p
:mysql -u <username> -p
.
.
.
我仍然收到警告。
错误 1045 (28000):用户“用户名”@“localhost”的访问被拒绝(使用密码:NO)
错误 1045 (28000):用户“用户名”@“localhost”的访问被拒绝(使用密码:YES)
每种情况一个,当我不输入密码时,以及当我输入密码时。
i am trying to access mysql into an remote server, and create a database there.
i am using putty to connect. the problem is that i get the "access denied" error
whatever i do:
:mysql -p
:mysql -u <username> -p
.
.
.
i still get the warning.
ERROR 1045 (28000): Access denied for user 'username'@'localhost' (using password: NO)
ERROR 1045 (28000): Access denied for user 'username'@'localhost' (using password: YES)
one for each occasion, when i do not enter a password, and when i do.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在远程访问 MySql 时遇到问题。从此处
首先,通过 ssh 登录到远程 MySQL 数据库服务器
连接后,您需要使用文本编辑器(例如vi)编辑mysql配置文件my.cfg。
在 Debian Linux 中,文件位于
/etc/mysql/my.cnf
确保注释了跳过网络行(或删除行)并添加以下行
,则整个块应如下所示:
例如,如果您的 MySQL 服务器 IP 是172.20.5.2
- 绑定地址:要绑定的IP地址。
-skip-networking :根本不监听 TCP/IP 连接。所有与 mysqld 的交互都必须通过 Unix 套接字进行。对于仅允许本地请求的系统,强烈建议使用此选项。由于您需要允许远程连接,因此应从文件中删除此行或将其置于注释状态。
重新启动 mysql 服务以使更改生效
第 5 步授予对远程 IP 地址的访问权限
# mysql -u root –p mysql
授予对新 IP 地址的访问权限数据库
如果你想为用户 bar 添加名为 foo 的新数据库,远程 IP 为 162.54.10.20,那么你需要在 mysql> 中键入以下命令:提示:
授予对现有数据库的访问权限
让我们假设您始终从名为 162.54.10.20 的远程 IP 与用户 webadmin 的名为 webdb 的数据库建立连接,那么您需要授予对此 IP 地址的访问权限。在mysql>提示符为现有数据库键入以下命令:
键入 exit 命令以注销 mysql
步骤#7:从远程系统键入命令
您还可以使用 telnet 连接到端口 3306 进行测试
You are having issues with remote access to MySql. From here
First, login over ssh to remote MySQL database server
Once connected you need edit the mysql configuration file my.cfg using text editor such as vi.
In Debian Linux file is located at
/etc/mysql/my.cnf
Make sure line skip-networking is commented (or remove line) and add following line
For example, if your MySQL server IP is 172.20.5.2 then entire block should be look like as follows:
Where
- bind-address : IP address to bind to.
- skip-networking : Don’t listen for TCP/IP connections at all. All interaction with mysqld must be made via Unix sockets. This option is highly recommended for systems where only local requests are allowed. Since you need to allow remote connection this line should removed from file or put it in comment state.
Restart your mysql service to take change in effect
Step # 5 Grant access to remote IP address
# mysql -u root –p mysql
Grant access to new database
If you want to add new database called foo for user bar and remote IP 162.54.10.20 then you need to type following commands at mysql> prompt:
Grant access to existing database
Let us assume that you are always making connection from remote IP called 162.54.10.20 for database called webdb for user webadmin then you need to grant access to this IP address. At mysql> prompt type following command for existing database:
Type exit command to logout mysql
From remote system type command
You can also use telnet to connect to port 3306 for testing purpose