Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to run mysql in ubuntu through terminal

Tags:

mysql

ubuntu

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...

like image 915
Raj Singhania Avatar asked Jun 25 '12 11:06

Raj Singhania


3 Answers

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;
like image 75
lorenzo-s Avatar answered Oct 01 '22 16:10

lorenzo-s


If you want to run your scripts, then

mysql -u root -p < yourscript.sql
like image 41
matcheek Avatar answered Oct 01 '22 15:10

matcheek


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.

like image 29
John Kane Avatar answered Oct 01 '22 15:10

John Kane