I'm logged into a CentOS server and I want to view all mysql databases. So I switched to the Linux root user and I tried logging into mysql. Normally (on other servers) I do this with a simple mysql command, but here I get an access denied:
[root#our.server.com kramer65]# mysql
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
I suppose that if I'm root on Linux I can do anything I want. Is there a way that I can show all Mysql databases as Linux root user?
From this you can log into your DB as linux root: if restarting servvices is an option:
https://www.digitalocean.com/community/tutorials/how-to-reset-your-mysql-or-mariadb-root-password
sudo systemctl stop mysql
sudo mysqld_safe --skip-grant-tables --skip-networking &
mysql -u root
Then the usual apply:
mysql>SHOW DATABASES;
The system root user is not the same as the root mysql user, and it's possible the system user has no access.
You can give the username to mysql with
mysql -u root -p
and enter the password for the mysql root user.
You can use the same command to connect with any mysql user account that is valid within mysql.
Related
I don’t remember my MySQL root password used in 'Bitnami WordPress Stack' (wordpress-5.4.2-0) in Linuy-Mint and tried the steps described here:
https://docs.bitnami.com/installer/apps/wordpress/administration/change-reset-password/
explicitly:
nano installdir/mysql/tmp/mysql-init
and saved it with:
ALTER USER 'root'#'127.0.0.1' IDENTIFIED BY 'NEW_PASSWORD';
then i restarted the MySQL server via Bitname App installdir/manager-linux-x64.run
i expected to be able in:
http://127.0.0.1:8080/phpmyadmin/index.php
with user root and NEW_PASSWORD but get then this error-message:
mysqli::real_connect(): (HY000/1045): Access denied for user 'root'#'localhost' (using password: YES)
This way is different to suggestions on: Bitnami. reset mysql root pwd
i tried also:
~/wordpress-5.4.2-0/mysql$ service mysql reset-password
mysql: unrecognized service
~/wordpress-5.4.2-0/mysql$ sudo dpkg-reconfigure mysql-server-x.x
and get the same errors in phpmyadmin.
if i use:
sudo /usr/bin/mysqld_safe --skip-grant-tables & mysql -h localhost
it got
Command 'mysql' not found, but can be installed
but of course its installed.
I have installed phpmyadmin on ubuntu ec2 instance. Phpmyadmin page is showing up in front page, but I am receiving error denying access to the root user. I had already set up password for the root during installation, but when I try to login using mysql -u root -p then I am getting error access denied for user 'root#localhost' (using password: YES). How can I setup root password so that I can login into phpmyadmin?
You can change the password of the root user as follows:
1.- Stop the Mysql service
service mysqld stop
O well:
/etc/init.d/mysqld stop
2.- Start the MySQL service in open mode with the following command:
mysqld_safe --skip-grant-tables --skip-networking &
3.- Once MySQL is started, you must access it with the user “root”. For this you can do it simply with:
mysql -u root
4.- Once inside MySQL, you will have to access the MySQL database, which is where you will have to change the password:
mysql> use MySQL;
5.- Within the MySQL database, you can launch the following query that will make the password change:
mysql> UPDATE user SET password = PASSWORD ('password') WHERE user = 'root';
6.- And when it finishes you will be able to leave the MySQL server with:
mysql> exit
7.- Finally you will have to restart the MySQL service so that it starts in normal mode:
service mysqld restart
O well:
/etc/init.d/mysqld restart
After completing the previous steps, you will have already modified the password of the MySQL “root” user.
I am trying to install mysql in my macbook pro (OS version: 10.15.2).
These are the steps I followed
Install mysql community server from this link
Install mysql workbench from this link
Open mysql from system preferences and click initialize database
set password for root user under initialize database
open .bash_profile through terminal and set path for mysql
export PATH=${PATH}:/usr/local/mysql/bin/
restart terminal to start mysql server with the following command
mysql -u root -p
enter the password set for root user from step 4
After all this I get the following error
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
Not sure what I am doing wrong.
This is the video I followed to install mysql in my system
[EDIT 1]
staring server with -skip-grant-tables
sudo mysqld_safe --skip-grant-tables
OUTPUT
2020-02-25T05:27:00.6NZ mysqld_safe Logging to '/usr/local/mysql/data/SASHAANKs-MacBook-Pro.local.err'.
2020-02-25T05:27:00.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
2020-02-25T05:27:02.6NZ mysqld_safe mysqld from pid file /usr/local/mysql/data/SASHAANKs-MacBook-Pro.local.pid ended
I believe the default authentication mechanism in MySQL 8 is auth socket. Try setting the root password like this:
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'my_password';
More on this here: https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/
If you can't access the CLI interface at all you should try manually resetting the root password as outlined here: https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html
Restart the mysql server with the --skip-grant-tables option.
Connect to the CLI (no password should be necessary)
FLUSH PRIVILEGES;
Reset root password as described above: ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'my_password';
Restart mysql normally
I installed MySQL using the following command:
sudo apt-get install mysql-server mysql-client mysql-common
It asks me for a root password (On package configuration), I enter one and confirm it.
sudo /etc/init.d/mysql start
However when I try logging in to mysql with user root and password which I supplied in the previous step, it denies me access:
root#mbilwebh02:/etc# > mysql --user root --password
Enter password:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES).
Another attempt that I made was to uninstall and reinstall mysql without supplying a password but that fails as well.
I then switched the user on the server to mysql
root#mbilwebh02:/etc# sudo -u mysql -s
root#mbilwebh02:/etc# sudo -u mysql -s
bash: /root/.bashrc: Permission denied
mysql#mbilwebh02:/etc$ mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
At this point I am able to only start and stop mysql. Any ideas where I might be going wrong?
[EDIT]
After searching a lot I found that one can log in to mysql using debian-sys-maint as user and password which is in the debian.cnf file. There was no 'root' user in the mysql database hence everything I tried denied me access.
I do not know if this is a safe way to do it though.
Taken from: http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html
Stop mysqld and restart it with the --skip-grant-tables option. This enables anyone to connect without a password and with all privileges. Because this is insecure, you might want to use --skip-grant-tables in conjunction with --skip-networking to prevent remote clients from connecting.
Connect to the mysqld server with this command:
shell> mysql
Issue the following statements in the mysql client. Replace the password with the password that you want to use.
mysql> UPDATE mysql.user SET Password=PASSWORD('MyNewPass')
-> WHERE User='root';
mysql> FLUSH PRIVILEGES;
The FLUSH statement tells the server to reload the grant tables into memory so that it notices the password change.
You should now be able to connect to the MySQL server as root using the new password. Stop the server, then restart it normally (without the --skip-grant-tables and --skip-networking options).
I have default root user in my percona mysql8 installation.
Problem: when I first sudo -s and then mysql -u root -prootpw, then I can connect to the mysql. But I also want to allow nonroot users (eg a java application running under a nonroot account) to use the default user.
But I'm just getting:
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1698 (28000): Access denied for user 'root'#'localhost'
So how can I force percona to allow root connections from localhost in non-root terminal users context?
mysql > ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'rootpw';
mysql > FLUSH PRIVILEGES;
$ systemctl restart mysql