I'm trying run a simple Java/MySQL web app tutorial in NetBeans.
I am able to connect to my database from a standard Java program in NetBeans, and Tomcat is working. But when I try to connect to the database from a JSP, I get the following error:
javax.servlet.ServletException: javax.servlet.jsp.JspException:
Unable to get connection, DataSource invalid:
"org.apache.tomcat.dbcp.dbcp.SQLNestedException:
Cannot create PoolableConnectionFactory
(Access denied for user 'root'#'localhost' (using password: YES))"
I know I have the correct password set, since other (Java SE) programs can connect to the database. Can anyone point me where to look?
I'm using NetBeans 6.7, MySQL 5.1, and Tomcat 6.0.18 in Windows Vista.
The username root can be used to login from the same machine only and not remotely. Try creating another user ID with all permissions.
have a look at Adding user accounts. In that page you will see two queries
CREATE USER 'monty'#'localhost' IDENTIFIED BY 'some_pass';
CREATE USER 'monty'#'%' IDENTIFIED BY 'some_pass';
Here the 2nd monty#% can be used to login remotely whereas the first is restricted to local login.
Related
I created an EC2 instance and installed mySQL in it.
Then, I ran the following commands...
create user 'developer'#'%' identified by 'password';
grant all privileges on *.* to 'developer'#'%' with grant option;
flush privileges;
Then, I created a connection to the remote mySQL server from MySQL workbench installed on my local system. Connection was successful.
Then, to connect my spring boot application to the remote mySQL server I changed the configuration in the 'application.properties' file as shown below -
spring.datasource.url=jdbc:mysql://localhost:3306/exam?serverTimezone=UTC
spring.datasource.username=developer
spring.datasource.password=password
But then when I tried to run the application, it showed the following -
Access denied for user 'developer'#'localhost' (using password: YES)
I searched for a solution on stackoverflow and one of the answers said '%' does not include 'localhost' and that a separate user should be created for localhost.
Hence, I created another user 'developer'#'localhost' with same privileges but still the issue remains unsolved.
I am setting up my local development environment using XAMPP for writing websites using Laravel.
The issue im facing is that I cannot connect to the MySQL database with any new user I create. I give one user limited privileges for only one database and cannot connect using the correct password.
I tried making an admin user with full privileges on all databases and tables, and still cannot connect with the correct password.
The returned error is always the same -
SQLSTATE[HY000] [1045] Access denied for user 'laravel'#'localhost' (using password: YES)
and
ERROR 1045 (28000): Access denied for user 'admin'#'localhost' (using password: YES)
where laravel is the username, admin is the other one etc.
This is not related to Laravel as I keep getting this error even when I try to connect from the command line (as shown in error code number 2).
The 'anonymous' user has been removed to make sure MySQL doesn't match it by mistake, I have flushed privileges and restarted services countless times.
The default root user without password can connect, but no new users that I create with passwords can.
Solved the problem by re-installing XAMPP, nothing else.
I created a new user in Mysql, with restricted privileges to do anything with only one VIEW ( GRANT ALL ON mydatabase.myview TO 'myuser'#'localhost'
When I try to connect with this user on DataStudio I got the message 'User denied" but when I try to connect using any other tool like sequel pro .. the connection is successful.
My question is: What Privileges are needed to connect with restricted users in DataStudio? They need to show all databases? show all tables? or any other grant ???
By setting 'myuser'#'localhost' you explicitly allow myuser to connect only from localhost aka your computer.
Google Data Studio operates on the Web, thus does not have access to your local network (see
https://support.google.com/datastudio/answer/7088031?hl=en#notes), unlike Sequel Pro which is running locally on your personal computer.
To start with, the correct user to create would be 'myuser'#'%'
I have two system where one system has the MySQL database (IP address is 192.168.0.149-running in centos) and the other has the web application (IP address 192.168.0.55-running in windows). I am calling the database from the web application remotely. I wanted to use ssh to connect with the database, so I use putty to do this.
First I run the putty and initiate the port forwarding from port 3535 to 192.168.0.149:3306.
I call from my application like this
orm.RegisterDataBase("default", "mysql", "john:john1#tcp(127.0.0.1:3535)/employee?
charset=utf8&parseTime=True")
I create a user in host MySQL database like this
mysql>create user john
mysql>GRANT CREATE,DELETE,SELECT,UPDATE ON employee.* TO 'rahul'#'192.168.0.55' IDENTIFIED
BY 'john1'
Now I run my web application. When I run it I'm getting the following error
[ORM]2017/03/01 16:18:57 register db Ping `default`, Error 1045: Access denied for user
'john'#'192.168.0.149' (using password: YES)
WORKING SCENARIOS
If I don't use the SSH and calling directly the database from the application then there is no problem for this user to access the employee database.
orm.RegisterDataBase("default", "mysql", "john:john1#tcp(192.168.0.149:3306)/employee?
charset=utf8&parseTime=True")
If I change the privilege condition like this then its working for ssh based remote database connection
sql>GRANT CREATE,DELETE,UPDATE,SELECT ON employee.* TO 'john'#'%' IDENTIFIED BY 'john1'
But I don't want to do this since it will accept the connection from all the system from the local network.I wanted to give the access to only 192.168.0.55.
Your credentials don't match.
You've granted access to 'rahul'#'192.168.0.55', but you're connecting as 'john'#'192.168.0.149'.
Try granting access to the user that's actually connecting:
GRANT CREATE,DELETE,SELECT,UPDATE ON employee.* TO 'john'#'192.168.0.149' IDENTIFIED BY 'john1'
I have to create a database in a Windows Server 2008 remote machine, which already had MySql Server 5.5 and MySql Workbench 5.2 installed. Since I wasn't granted the password to the root user, I tried to create a new user.
In MySql Workbench I tried to open the Manage Security option, to no avail, since it asked for the password.
In the command prompt I tried to run mysql but it returned the following error message.
ERROR 1045 (28000): Access denied for user 'ODBC'#'localhost' (using password: NO)
Is there any way to create a new user without having prior access to the root user?
More generally, is there any workaround to create and use a database without access to root?
You don't have to be the root user, but you must have rights to create a user. You can get those rights with the grant create user statement. Apparently, you don't have those privileges, so if you need them, you should ask your administrator.
So the answer is: There is no workaround. You don't have to be root, but you must have certain privileges.
In practice, if you need an extra user, the administrator is more likely to create one for you than to give you the rights to create them yourself. But that's something he and you need to figure out yourselves. :)