Failed to setup server and failed to connect to the specified database

Oh sorry! the issue is with the password to the root. The root password you are supposed to use is the one you created while installing mysql.

@sahilm0704 you can still confirm the password on the run time properties file by following this path.

On windows machine:

C:\Documents and Settings\YOURUSERNAME\Application Data\OpenMRS
C:\Windows\system32\config\systemprofile\Application Data\OpenMRS

On Mac OS X or Linux systems:


@sahilm0704 please check with shell and check if your able to login into mysql using the root password. If not you will have to reset the password since you have forgotten it. Please follow these steps to reset the forgotten root password

To change the MySQL root password, you first need to shut down the MySQL server, and you can do so using the command: sudo systemctl stop mysql.service

Skip Grant Tables & Networking

sudo systemctl set-environment MYSQLD_OPTS="–skip-networking --skip-grant-tables"

Start the MySQL service

sudo systemctl start mysql.service

Sign In to the MySQL shell

Now, you need to login as a root user to the MySQL server and for signing in to the MySQL shell, type the command: sudo mysql -u root

Select the MySQL database. use mysql

Now ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘the-new-password’;

Then: flush privileges; That’s all exit mysql shell and try logging in again. sudo mysql -uroot -p If successful please use the same information while setting up the server

1 Like

this didn’t work out

But is the mysql shell login success?

no… even after resetting the password i’m getting error and not able to log in to the MySQL ERROR 1698 (28000): Access denied for user ‘root’@‘localhost’

Please use this code on mysql reset:

UPDATE mysql.user SET authentication_string = PASSWORD(‘new_password’) WHERE User = ‘root’ AND Host = ‘localhost’;

after running this command i got his error: ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘(‘qwert’) WHERE User = ‘root’ AND Host = ‘localhost’’ at line 1

First stop mysql service: sudo systemctl stop mysql

Reset password: sudo mysqld_safe --skip-grant-tables --skip-networking &

Login after reset: mysql -u root

Flush privileges: FLUSH PRIVILEGES;

Alter password: ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘new_password’;

UPDATE mysql.user SET authentication_string = PASSWORD(‘new_password’) WHERE User = ‘root’ AND Host = ‘localhost’;

Start the service again: sudo systemctl start mysql

Now login with the new password: mysql -u root -p

By the way which version of Mysql are you running??

mysql Ver 8.0.27-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))

got this error: 2022-01-07T08:46:35.985833Z mysqld_safe Logging to ‘/var/log/mysql/error.log’. 2022-01-07T08:46:35.988914Z mysqld_safe Directory ‘/var/run/mysqld’ for UNIX socket file don’t exists.

If its a fresh installation for mysql and You don’t have important databases; please uninstall and reinstall mysql package in ubuntu. That would solve the problem once and for all.

Thanks @abertnamanya. It worked

1 Like