I've searched a lot but nothing works for me.
I have a fresh installation of a LAMP server, installed via tasksel command.
My system runs php 7.4 and MySql 8
For some reason root user (that in my case is called phpmyadmin, by default) has no privileges on the DBs.
I can log in, so I'm sure the password is correct, but I cannot create a Database.
$ mysql -u phpmyadmin -p
mysql > create database test;
Access denied for user 'phpmyadmin'#'localhost' to database 'test'
EDIT
As suggested, here's the output of
mysql> SELECT name, Create_priv FROM mysql.user;
SELECT command denied to user 'phpmyadmin'#'localhost' for table 'user'
NEW EDIT
I tried to access without the password, following the guide reported here:
...
No results for me :(
Stop the MySQL Server: sudo /etc/init.d/mysql stop (OK)
Start the mysqld configuration: sudo mysqld --skip-grant-tables
output:
[2] 2345
[1] Exit 1 sudo mysqld --skip-grant-tables
Run: sudo service mysql start
output
[2]+ Exit 1 sudo mysqld --skip-grant-tables
It seems to exit with errors... Am I wrong?
I also tried to login in that situation, but I receive this message "ERROR 1698 (28000) Access denied for user 'root'#'localhost'"
If I try my phpmyadmin user, the message is "ERROR 1045 (28000): Access denied for user 'phpmyadmin'#'localhost' (using password: NO)"
EDIT 06/19/2020
I followed the steps reported here
How to reset or change the MySQL root password?
I had to use MD5() instead of PASSWORD() because it's now deprecated.
There's still something wrong.
Now I can access the database with no privileges and set/change my password.
Then I can flush all privileges.
Then I try...
mysql -u root -p
I enter my new password...
ERROR 1698 (28000): Access denied for user 'root'#'localhost'
I can still log in with the user set in phpMyAdmin, but there are still no privileges for me.
I also reinstalled MySql server.
I remember I had a similar problem last time I installed an old Linux Virtual Machine, but I solved that issue easily. Now I'm wondering what's wrong :(
SOLVED
I reinstalled my virtual machine and installed manually both php and mysql server.
To be sure to set privileges in the right way I followed this small guide... maybe helpful for someone.
https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-20-04
Bye!
Related
I installed mysql in Ubuntu 20.04.
Problem -
Case 1: I have default root user. I can login using sudo mysql but cannot login using mysql -u root -p.
Case 2: I created another user 'local'. I can login using mysql -u local -p and by giving password I set. But problem is if I give wrong password, it still logs me in. I don't know why.
I followed this ERROR 1698 (28000): Access denied for user 'root'#'localhost'
but this didn't help me. I followed other topics too like creating new user for mysql etc.
I cannot access from workbench or from python script too.
Error : ERROR 1698 (28000): Access denied for user 'root'#'localhost'
Login to mysql using sudo mysql -u root
Give your su password and it will login without mysql password.
Run following commands:
USE mysql;
UPDATE user SET plugin='mysql_native_password' WHERE User='root';
FLUSH PRIVILEGES;
exit;
Restart:
sudo systemctl restart mysql.service
After that, run commands to secure MySQL server and create a new root password.
sudo mysql_secure_installation
When prompted, answer the following questions :
New password: Enter password
Re-enter new password:
Repeat password
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y
Next time, type following command in terminal to login:
sudo mysql -u root -p
Then type mysql password you set recently to sign in.
Good Luck, this worked for after continuous wasting several hours on this thing and following tens of tutorials.
By doing this, I was finally able to establish connection in workbench and in my python scripts.
I'm having a weird problem where I cannot login to my MySQL server with sudo as root on a ubuntu 19.10 server. I want to be able to reset my root password.
The error message I got was:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
Anyone had similar problems? Thanks!
Ok - so I solved this problem myself.
The correct way of resetting the root password for mysql is to:
Stop all mysql server sessions.
Start mysqld manually using - this basically tells MySQL to skip any credentials check and allow anyone to login, hence you want to skip-networking to avoid network users.
sudo mysqld --skip-grant-tables --skip-networking
Use this to login as root:
sudo mysql -u root
In the mysql prompt, do:
FLUSH PRIVILEGES;
SET PASSWORD FOR root#'localhost' = PASSWORD('password');
FLUSH PRIVILEGES;
Stop mysqld and restart mysql normally (you may need to kill the mysqld process).
In my case, there was some problems with the installation and the /var/run/mysqld folder was not correctly set up. It may be a bug with MySQL and it was not properly reported.
After creating the folder with the correct setmod (user:group is mysql:mysql) mysqld runs without any problem.
I finally decided to post my question as I am encountering high difficulties to connect to the mysql client.
I am using a mySQL database on an OpenWRT OS installed on an Arduino Yun.
I cannot log into mySQL as root, the following error message is displayed:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using
password: NO)
I tried with suffix -u root (or -uroot) and suffix -p and a supposed password but every time it turns out to be the same error, sometimes with (using password: NO), other times with (using password: YES)
Reading some posts, I tried all the following manipulation :
kill mysqld and then run
mysqld with --skip-grant-tables
It works and I can log into mysql but any operation proposed to UPDATE the password for user root turns a QUERY OK with 0 rows modified. It should be normal I suppose, as I am not log with grant tables I have no access to user informations and privileges.
Note that when I run
SELECT user();
or
SELECT current_user();
I get root# with nothing following.
Re-installing the databases using the script mysql_install_db. It does not work as is saying that no host "Arduino" or "localhost"could be looked up with /usr/bin/resolveip (nota: no such thing in that folder)
using the --force option it works.
I tried what is exposed in the following post SOLVED - MySQL - Can't Log In - Access Denied - Brand New Installation (OpenWRT)
With the command line
mysqladmin -uroot password pwd
I ended with the same answer :
error: 'Access denied for user 'root'#'localhost' (using password:
NO)'
Could anybody help me or tell me what is the cleanest way to uninstall and fully reinstall MySQL on OpenWRT?
Thank you
Well, yeah...
mysqladmin -uroot password pwd
^--missing --
Since you don't specify the password option correctly, you're effectively passing NO password to mysqladmin, and it doesn't log you in.
Try
mysqladmin -u root -p pwd
mysqladmin --user=root --password=pwd
instead.
I just installed Mysql for the first time on a CentOS machine using yum. The installation had no errors. Then I followed those steps:
$ sudo /sbin/service mysqld start --skip-grant-tables --skip-networking
$ sudo /usr/bin/mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
Enter current password for root (enter for none):
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
Enter current password for root (enter for none):
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
Enter current password for root (enter for none):
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
Enter current password for root (enter for none):
It can be seen that even after first installation there is issue in logging in to the DB. I have even tried all command in sudo, but the error is still there. I can't even figure out how to reconfigure MySQL. I halso have installed-removed mysql 3 times.
How can I solve this issue?
Just for anyone who has this issue on MySQL 5.7. or higher.
MySQL v 5.7 or higher generates a temporary random password after installation and stored that in mysql error log file, located at /var/log/mysqld.log
for an installation by the MySQL Yum repository on CentOS 7.
use below command to see the password:
sudo grep 'temporary password' /var/log/mysqld.log
Ref: MySQL 5.7.7 - Centos 7 el7 - Access denied
EDIT1
For anyone that has different error log file, you can find it using #Drew's answer here below.
Maybe you already setted it at some point. You can try this:
yum remove mysql-server
rm -rf /var/lib/mysql
yum install mysql-server
systemctl start mysqld.service
/usr/bin/mysql_secure_installation
Anyway, I think this question should be in ServerFault.
A visual of the temporary root password written to the Error Log file
Not that one can exactly rifle off the command
select ##log_error;
to find the location of the Error Log file without logging in (a which came first, the chicken or the egg predicament).
But the typical locations are
C:\ProgramData\MySQL\MySQL Server 5.7\Data\
(for Windows. You must unhide the C:\ProgramData dir)
and
mysql> select ##log_error;
+---------------------+
| ##log_error |
+---------------------+
| /var/log/mysqld.log |
+---------------------+
(for Linux)
sudo mysql_secure_installation
When it asks for password type pass
Follow the prompts to change the root password
you misunderstood. Because of you havn't set the password yet. you should just
enter for none.
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
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).