Saturday, May 11, 2013

Operate mysql from command line

Use mysql using command line :

First install mysql client using command line.
apt-get install mysql-client or yum install mysql-client according to your Linux distribution.

Now go on mysql prompt using
$ mysql -h 127.0.0.1

If you want to log-in with root using command line
$ mysql -h 127.0.0.1 -u root

Root's password is blank. If it asks for password, do not write anything, just press Enter key.

$ mysql -h 127.0.0.1 -u root -p


Do not try to log-in with password protected user using command line.

If you try to log-in with password protected user, it gives following error :
ERROR 1045 (28000): Access denied for user 'admin'@'localhost' (using password: YES) 

No comments:

Post a Comment