Reputation: 333
trying to run mysql in ubuntu
typing mysql
in terminal
and getting error
ERROR 1045(28000): Access denied for user 'root'@'localhost' (using password: NO)
Can anybody please sort out this problem...
Upvotes: 30
Views: 134517
Reputation: 121
You can actually access mysql prompt command by directly doing :
sudo mysql
If you would like to access it the "regular" way with sudo mysql -u <theuser>
, this answer solved it at 100% for me :
https://askubuntu.com/a/784347
Upvotes: 0
Reputation: 1022
You seem to just have begun using mysql.
Simple answer: for now use
mysql -u root -p password
Password is usually root by default. You may use other usernames if you have created other user using create user in mysql. For details use "help, help manage accounts, help create users" etc. If you dont want your password to be shown in open just press return key after "-p" and you will be prompted for password next. Hope this resolves the issue.
Upvotes: 0
Reputation: 4443
You need to log in with the correct username and password. Does the user root have permission to access the database? or did you create a specific user to do this?
The other issue might be that you are not using a password when trying to log in.
Upvotes: 2
Reputation: 5147
If you want to run your scripts, then
mysql -u root -p < yourscript.sql
Upvotes: 7
Reputation: 17010
You have to give a valid username. For example, to run query with user root
you have to type the following command and then enter password when prompted:
mysql -u root -p
Once you are connected, prompt will be something like:
mysql>
Here you can write your query, after database selection, for example:
mysql> USE your_database;
mysql> SELECT * FROM your_table;
Upvotes: 55