问题描述
我有一个问题,使用phpMyAdmin创建和栅格权限的用户。我有一个Java swing应用程序,它需要连接到此数据库。
我如何创建用户并授予权限,如下,一步一步。 >
- 打开phpMyAdmin
- 转到用户标签。
- 点击添加新用户
- 输入用户名,选择 Any Host 作为主机(所以%显示在其文本框中),并提及密码。 任何主机是因为需要远程访问。
- 选择 c $ c>全局特权 - 数据
- 单击 code>
- 现在我在用户标签的开始页。
- 点击我新创建的用户的编辑权限。
- code>数据库特定
- 在下选择所有数据库特定的权限,<$
- 点击 Go / ol>
- 使您的用户。
- 点击修改权限。
- 更改任何主机的本地主机。
-
-
- 滚动到底部,
- 确保保留旧密码并按Go。
- Open phpMyAdmin
- Go to 'Users' tab.
- Click on Add New User
- Give the user name, select Any Host as the host (so the % is displayed in its text box), and mention the password. Any host is because remote access required.
- Select Select under Global Privileges - Data
- Click on Go
- Now I am in the Users tab starting page again.
- Click on Edit Privileges on my newly created user.
- Select the database under Database-specific privileges
- Tick everything under Database-specific privileges, Data section.
- Click on Go
- After you have made your user.
- Click edit priviliges.
- Change Any Host for Localhost.
- Apply your priviliges.
- Scroll to the bottom and
- make sure that "keep old one" is selected and press Go.
现在,每当我的Java应用程序连接到这个,它会给出以下错误
java.sql.SQLException:拒绝访问用户'userName'@'localhost'(使用密码:YES)
这是我在我的Java应用程序中连接到数据库的方法
con = DriverManager.getConnection(jdbc :mysql://+ ip +:3306 / databaseName,user,password);
这里,对于变量 ip 尝试了 localhost 和 127.0.0.1 ,但仍然没有好。我做错了什么?
我注意到如果我选择 Localhost 而不是任何主机
$
I am having an issue with creating and grating permissions to a user using phpMyAdmin. I am having a Java swing application and it need to connect to this database.
How I created the user and granted the permission are below, step by step.
Now, whenever my Java application connects to this, it gives the below error
java.sql.SQLException: Access denied for user 'userName'@'localhost' (using password: YES)
This is how I connect to the database, in my Java application
con = DriverManager.getConnection("jdbc:mysql://"+ip+":3306/databaseName","user","password");
Here,for the variable ip, I tried both localhost and 127.0.0.1 but still no good. What have I done wrong?
I noticed the connection works fine if I select Localhost instead of Any Host in step 4.
这篇关于MySQL:拒绝访问用户'userName'@'localhost'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!