Exception in thread "main" java.sql.SQLException: Access denied for user 'root'@'liugonli' (using password: YES)
时间: 2023-10-28 08:59:39 浏览: 34
这个异常"Exception in thread "main" java.sql.SQLException: Access denied for user 'root'@'liugonli' (using password: YES)"是指用户访问被拒绝的错误,原因是密码不正确。根据引用中的信息,你明确配置了正确的密码,但是问题出现在yml文件的配置上。你可以检查一下yml文件中的数据库配置是否正确。同时,根据引用中的描述,你使用了逆向工程-MyBatis Generator来生成代码,在代码中指定了一个mbg.xml文件作为配置文件。你发现问题是因为这个mbg.xml文件中的数据库密码没有正确修改。请确保你的mbg.xml文件中的数据库配置正确,并将密码修改为正确的密码,然后再次尝试运行代码。
相关问题
java.sql.SQLException: Access denied for user root@localhost (using password: YES)
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) 是一个常见的数据库连接错误,表示用户'root'在本地主机上使用了错误的密码进行连接。
解决这个问题的方法有以下几种:
1. 确保用户名和密码正确:首先,确保你使用的用户名和密码是正确的。检查你的数据库配置文件或者数据库管理工具中的用户名和密码是否与你尝试连接的数据库一致。
2. 检查数据库权限:如果用户名和密码是正确的,但仍然无法连接数据库,可能是因为该用户没有足够的权限访问数据库。请确保该用户具有正确的权限,包括连接数据库和执行所需的操作。
3. 检查数据库连接字符串:检查你的数据库连接字符串是否正确。确保连接字符串中的用户名、密码和数据库名称都是正确的。
4. 检查数据库服务器配置:如果以上方法都没有解决问题,可能是因为数据库服务器的配置有问题。请检查数据库服务器的配置文件,确保允许远程连接,并且没有其他限制。
5. 检查防火墙设置:有时候,防火墙设置可能会阻止数据库连接。请确保你的防火墙允许数据库连接。
6. 重置密码:如果你确信用户名和密码是正确的,但仍然无法连接数据库,可以尝试重置密码。使用数据库管理工具或者命令行工具重置密码,并更新你的应用程序中的连接信息。
这些方法应该能够帮助你解决java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)错误。
java.sql.SQLException: Access denied for user root @ localhost (using password: YES)
This error message indicates that the user "root" is being denied access to the database server at "localhost" because the provided password is incorrect.
There are a few possible reasons why this might be happening:
1. The password for the "root" user has been changed or forgotten.
2. The "root" user has not been granted proper privileges to access the database server.
3. There is a typo or error in the connection string that is being used to connect to the database server.
To resolve this issue, you should verify the following:
1. Make sure that the password being used to connect to the database server is correct. If you have forgotten the password, you may need to reset it.
2. Check that the "root" user has the necessary privileges to access the database server. You can do this by logging into the database server with another user account that has administrative privileges and granting the necessary permissions to the "root" user.
3. Verify that the connection string being used to connect to the database server is correct, and that there are no typos or errors.