So I'm setting up mysql for the first time.
I read somewhere that I have to run this
mysql -u root -p
To log in as root, in order to be able to create tables/databases using the mysql command line.
When I run this, I get prompted for a password - I hit enter (I thought the default password was blank).
I get this error
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
What's going on?
If you have a fresh installation of MySql you should be able to issue the following command and it should allow your connection.
xyz#ubuntu$ mysql -u root mysql
You then should set the root password and then create a user with the correct level of access.
look HERE for help connecting.
Related
I just set up mysql server 8.0 on my local machine. The first time login was fine and I created my database and everything, but since I wanted to load local files so I exited and did mysql -u root -p --local-infile databasename;. When I did that it gave me ERROR 1049 (42000): Unknown database 'databasename;'. Then I tried to login using mysql -u root -p to check the database but I got this error: ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
I tried to restart mysqld but new error message pops up. And I tried to reset the root password it didn't work either.
So I tried to reinstall mysql. The exact same thing happened. The first time login was fine, but when I exit and did --local-infile databasename it said Unknown database 'databasename; again.
Could someone help me with this issue? Thank you! I'm using the widows system.
First I would recommend installing MySQL Workbench, which is the "official" MySQL GUI. It's not that great, but it makes troubleshooting these sort of problems much easier.
Next, If you can actually connect to your localhost instance with workbench, run this:
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'yourPasswordHere'
If not, try reinstalling MySQL again and see if you can connect.
For the last few years I logged in to my local mysql database by simply typing mysql on Terminal. But now, for some reasons I found that this doesn't work right now, with the access denied error:
ERROR 1045 (28000): Access denied for user 'me'#'localhost' (using password: NO)
Now I must log in to type the following:
mysql -uroot -proot
This is quite painstaking, so I rather want to swich back to when I just type in mysql to log in to the database.
I don't set it as an alias in my zsh shell, but I cannot remember how I set it way before, such that I don't need to type in my user and password.
So how can I set it such that I log in with mysql command only? I use Mojave beta.
I think your current connection has set up with a password try to create new connection with null or leave it blank when asking a password :)
I am trying to access my MySQL server from the command prompt. I typed in this command:
c:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -u root -p
Then I entered my password when prompted and got this error message:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
I'm not too experienced with MySQL or the command line interface so I'm not sure what this error message means. I've tried watching some youtube videos on different ways to do this but I keep on getting the same error. Any help on this would be appreciated. Thanks!
It means your attempt to get authenticated failed.
That is probably because you are using the wrong password for the "root" user in your mysql instance. When you say "entered my password" do you mean you entered the password you set for root when you installed mysql, or do you mean the password you have for your user account on that computer?
It needs to be the mysql password for the user in mysql named "root". Note that this has nothing to do with any users in the operating system that is running this instance of mysql.
Check your choice of password and make sure you use the mysql "root" user password. Or if you have the credentials (that is, the user name and password) for a different user in the mysql instance, use those instead.
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.
Please forgive me for being a complete beginner:
I am trying to log into my very first mySQL database that I installed using easyPHP on my windows machine, using the cmd line. I am going to the \mysql\bin and entering the command:
mysql -u root
in order to log in, but I am getting the following message:
error 1045 (28000) access denied for user 'root'#'localhost' (using password: YES)
Why is it using the password "YES"? Shouldn't there be no password at all? Do I need to restart mySQL or something? If so, how do I do that? If it's relevant, I did try to create the database using phpmyadmin, but had a few problems entering columns and decided I'd be better off working from the command line so I could learn all the commands as I went along.
Please keep in mind that this is my first time ever trying to work with a database, so be kind to me!
To have mysql asking you for a password, you also need to specify the -p-option:
mysql -u root -p
When logging into MYSQL using the command line, you also have to specify the password if any. Your error message is telling you that the user "root" has a password attached to it. Not necessarily that the password is "YES" when you were installing easyPHP, it should have either provided you with a default password or allowed you to enter a password of your choosing.
According to the documentation of easyPHP:
[v1.6] My scripts worked perfectly with 1.5 but now I get this error : Warning: Forbidden access for user: 'user#localhost' (password: YES) when I want to connect to MySql.
Only the root user (without password) has the rights to connect to the database. Either modify your scripts to use it, or add the user you need (phpMyAdmin/users and privileges: See phpMyAdmin's documentation for more information).
mysql -u root -p
Now if you changed your root user password, you will need to specify that when prompted. Otherwise simply hit <Enter> on your keyboard.
If you FORGOT the password to root, and have changed it, you will have to subsequently reinstall easyPHP.
agk-hp:~/$mysql
ERROR 1045 (28000): Access denied for user 'greg'#'localhost' (using password: NO)
agk-hp:~/$sudo cat /etc/mysql/debian.cnf|grep password
password = t7753my3D2x4yfQm
agk-hp:~/$mysql -u debian-sys-maint -p
Enter password: {t7753my3D2x4yfQm}
Welcome to the MySQL monitor. Commands end with ; or \g.
mysql> use mysql;
mysql> grant all privileges on *.* to 'root'#'localhost';
mysql> grant all privileges on *.* to 'greg'#'localhost';
agk-hp:~/$mysql
mysql>
A modification for mysql- 5.7.10 on mac mac el capitan
sudo /usr/local/mysql/support-files/mysql.server stop
sudo mysqld_safe --skip-grant-tables
Now open new window/tab on terminal and type
"mysql -u root"
use mysql
update user set authentication_string=password('yourpassword') where user='root';