I have been trying to install a new version of Sonar, however after this did not work (due to a table_lock error with the database migration) I have referred back to the original version 2.11. Now when I start tomcat I get this exception (attached). I have been changing the my.cnf and some things may have been reset.
In the catalina.out log I get this error:
... 42 common frames omitted
Caused by: java.sql.SQLException: Access denied for user 'sonar'#'localhost' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075) [mysql-connector-java-5.1.13.jar:na]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3566) [mysql-connector-java-5.1.13.jar:na]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3498) [mysql-connector-java-5.1.13.jar:na]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:919) [mysql-connector-java-5.1.13.jar:na]
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4004) [mysql-connector-java-5.1.13.jar:na]
Looks like your Sonar database no longer has access granted for the sonar user. To fix it, type "mysql" from a command prompt and do the following:
mysql> GRANT ALL ON your_sonar_database TO 'sonar#localhost' IDENTIFIED BY 'password_for_sonar_user';
mysql> FLUSH PRIVILEGES;
mysql> exit
Then restart the Sonar server and you should be good.
Related
I am trying to connect a Spring Boot Application to my MariaDB server which is up and running. I am getting the following error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource
...
Caused by: liquibase.exception.DatabaseException: java.sql.SQLException: Access denied for user 'root'#'localhost' (using password: YES)
Now I've seen that similar questions have been asked on Stackoverflow before, and I tried the most common approaches, like granting all privileges:
GRANT ALL PRIVILEGES ON *.* TO 'root'#'localhost' IDENTIFIED BY '%password%' WITH GRANT OPTION;
And removing the password for the root user:
SET PASSWORD FOR root#localhost=PASSWORD('');
None of these approaches worked so far. I cannot really change the .properties file, but from what I can see a password is generated, encrypted and stored every time the application runs:
connection.driver_class = com.mysql.jdbc.Driver
connection.url = jdbc:mysql://127.0.0.1:3306/local02?useSSL=true
connection.username = root
connection.password = ../../config/local/dbkey.txt
connection.pool_size = 200
It's important to highlight that I am experiencing this problem just on MacOS, on Windows (same files, same DB, same IDE) doesn't arise.
Is there anything else I can try?
As far as I know Spring does not allow to use the root user of mariaDB. You must create a new user and grant priviledges.
I'm using MySQL on windows (I wish I was using Mac, but due to some issues I'm using Bootcamp), and I've encountered a problem I think I've encountered before: the error that is written in the title. I think I might have solved this once before by erasing MySQL through the control panel and by erasing everything in the hidden folder, ProgramData, and MySQL from ProgramFiles, then reinstalling it. It is such a hassle and consumes a lot of time. It definitely isn't something I can do repeatedly to solve this problem if I get an error like this again and again.
The problem:
I simply ran this code on CMD after "cd"ing to the bin folder that contains mysql: mysql -u root -p PASSWORD but I get the error written in the title. Thus I can't login to mysql and run any lines to edit the database.
There are so many other topics like this in stackoverflow:
MySQL Error: : 'Access denied for user 'root'#'localhost'
Access Denied for User 'root'#'localhost' (using password: YES) - No Privileges?
https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html
I tried implementing the solutions from the three links above. Many other advices advise to use the "sudo" command, which is not a windows command.
This is the line I get from implementing the solution given to me by dev.mysql.com (#3):
This is the line of code I ran in CMD:
mysqld --init-file=C:\\mysql-init.txt --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" --console
This is the code I ran to implement the solution in link #2:
mysqld --skip-grant-tables --skip-networking --console
and the code I get back:
Things to note:
Each time, I get this line of code back from the console:
[Warning]...[Server] CA certificate ca.pem is self signed.
In the first picture, this is the "ERROR" I get from the console: [ERROR]...[Server] unknown variable 'defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini'
In the second picture, this is the "ERROR" I get from the console: [ERROR] TCP/IP --shared memory, or --named-pipe should be configured on NT OS
This is the line of code I would put in in mysql-init.txt: ALTER USER 'root'#'localhost' IDENTIFIED BY 'PASSWORDHERE';
or this: INSERT INTO mysql.user (Host, User, Password) VALUES ('%', 'root', password('YOURPASSWORD'));
GRANT ALL ON *.* TO 'root'#'%' WITH GRANT OPTION;
I installed MySQL through the installation wizard.
Q. How did I encounter this error?:
A. I was experimenting on a project for a back-end Spring Boot project that uses JPA and JDBC combined. I got errors telling me that no datasource could be configured.
Q.How did my root password get reset?
A.I think they got reset because of JPA's datasource autoconfiguration. I didn't touch any of mysql's settings myself. Something I did on Spring Boot and its automatic configuration to localhost must have reset the password.
I will say that uninstall your MySQL and again install it with a new instance but not like just uninstall it from the control panel that's why you are facing the same error every time. I already answered here in detail that how to remove properly so no error will come by creating a new instance.
For anyone encountering this issue after they initialized their mysql server with following command:
mysqld --initialize
Look out for the last output of the process, it should say something like this:
[Note] [MY-010454] [Server] A temporary password is generated for root#localhost: password12345
there is your temporary password to log in.
I've been using MAMP out of convenience but have run into major problems after mistakenly changing root permissions. I have not been able to resolve these problems and have opted for a fresh install of MAMP and moving over the db folders, which I read was possible. In doing so, I have a number of DBs which have tables that are MIA.
SHOW GRANTS FOR 'root'#'localhost'
response:
GRANT ALL PRIVILEGES ON *.* TO 'root'#'localhost' IDENTIFIED BY PASSWORD '*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B' WITH GRANT OPTION
GRANT PROXY ON ''#'' TO 'root'#'localhost' WITH GRANT OPTION
I can see the all the tables in the db folder but not all are not showing up in phpmyadmin.
I believe phpmyadmin connects as a socket "Server: Localhost via UNIX socket"
When I login into the console as root/localhost I can see all the tables.
Loggin into the console as root/127.0.0.1 I cannot see the DB at all.
I'm really stuck here and have pretty much lost a day of work because of this.
Update:
When I run mysql_update command I get the following response.
→ /Applications/MAMP/Library/bin/mysql_upgrade -p
Enter password:
Looking for 'mysql' as: /Applications/MAMP/Library/bin/mysql
Looking for 'mysqlcheck' as: /Applications/MAMP/Library/bin/mysqlcheck
Running 'mysqlcheck with default connection arguments
Running 'mysqlcheck with default connection arguments
ipbnew.ipb_admin_login_logs
Error : Table 'ipbnew.ipb_admin_login_logs' doesn't exist
status : Operation failed
ipbnew.ipb_admin_logs
Error : Table 'ipbnew.ipb_admin_logs' doesn't exist
status : Operation failed
I've posted a full explanation of the solution to my problem in a separate SO topic.
MAMP mysql broken root user
I am trying to setup the connection to a Mysql database. However I am getting a user error saying that:
WindowsApplication1.vshost.exe Error: 0 : Access denied for user 'Root'#'myiphere' (using password: YES)
A first chance exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll
I have used this....
GRANT ALL PRIVILEGES ON permissionsex.* TO root#'%' IDENTIFIED BY 'password';
But the error is still there.
In your error message I can see you're using the username Root but you granted rights to root. Mind the lower-case versus upper-case r.
I am trying to add Sonar to my Continuous Integration build system. I am using ANT as my build script and I am using the sonar-ant-task-1.1.jar for sonar to generate the reports based on my source code in SVN.
Problem
When the build runs and hits the sonar ant task I get the exception as follows:
Caused by: java.sql.SQLException: Access denied for user 'sonar'#'glassfishdev.ccs.local' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3566)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3498)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:919)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4004)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1284)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2312)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2122)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:774)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:375)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:289)
at org.sonar.jpa.session.DriverProxy.connect(DriverDatabaseConnector.java:160)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at org.sonar.jpa.session.DriverDatabaseConnector.getConnection(DriverDatabaseConnector.java:95)
at org.sonar.jpa.session.AbstractDatabaseConnector.testConnection(AbstractDatabaseConnector.java:185)
... 40 more
What I have done
1. Install MySQL database.
2. Create the sonar database, sonar user, and grant permissions by using the script provided in the sonar installation
**CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'sonar' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'#'%' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'#'localhost' IDENTIFIED BY 'sonar';
FLUSH PRIVILEGES;**
3. Added the following to my build script
4. Added the following external variables in Jenkins Freestyle build project
sonar.jdbc.url=jdbc:mysql://10.120.21.12:3306/sonar?useUnicode=true&characterEncoding=utf8
sonar.jdbc.driverClassName=com.mysql.jdbc.Driver
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.host.url=http://10.120.21.12:9000/
5. I was also available to connect to the database through my sql client tool to verify that the database, user and permissions statements were executed correctly.
However when Jenkins runs the build it does not seem to know how to connect to the MySQL database.
Any thoughts?
The solution was to run the following command:
GRANT ALL ON *.* TO 'sonar'#'%';
The right solution is this:
GRANT ALL PRIVILEGES ON `sonar`.* TO 'sonar'#'localhost';
As explained here, connections to localhost occur over a UNIX domain socket. You are likely logging in as an anonymous user to localhost (e.g. ''#localhost).
I just tried it with sonar 4.5.2 with grants only on sonar.* and its definitely not working.
It looks like sonarqube requires additionnal privileges to work, personnaly i haven't identified which ones yet, and i'm still using a grant all on the database.