Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

accessing phpmyadmin db from terminal now in ubuntu 13.04 i firstly installed mysql server with sudo apt-get install mysql-server mysql server version 5.5 now in terminal i can check if it is working by

sudo netstat -tap | grep mysql

it responds me by prompting me for password and then

tcp        0      0 localhost:mysql         *:*                     LISTEN             26214/mysqld

but to connect using my root account i typed mysql -u root -p prompting for password it shows ERROR 1045 (28000): Access denied for user 'username'@'localhost' (using password: YES)

when i try this /opt/lampp/bin/mysql -u root -p it ask for password and says ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/lampp/var/mysql/mysql.sock' (2)

what is there in /etc/mysql/my.cnf and what is in /opt/lampp/bin/mysql

any solution?

share|improve this question
up vote 4 down vote accepted

Have you tried setting up password for root soon after installing MySQL?? If not first try to Enter the command in a terminal below;

mysql -u root

Now it should open the mysql console. And type the following line:

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword');

To exit from the mysql console enter exit.

Then try reconnecting with following line;

mysql -u root -p

Try the password you've entered.

Source: How to connect and create a database in MySQL?

share|improve this answer
but when i again try to connect by mysql -u root -p its showing `ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) – black Jan 21 '14 at 15:26
this error came after try the above steps?? – AzkerM Jan 21 '14 at 17:26
yes. could not open phpmyadmin from localhost xampp. – black Jan 21 '14 at 21:34

yes man.after i followed those steps i was able to connect to phpmyadmin from terminal but after a restart i see i cant access phpmyadmin from localhost

#2002 - No such file or directory The server is not responding (or the local server's socket is not correctly configured) and also status from localhost shwing mysql database deactivated . all other like SSI,PHP,CGI is activated. in security section its howing phpmyadmin as unknown and mysql user root no password unknown.

before it was all activated and secured i have done that to set password for root and localhost with all preveiledged when i installed xampp in linux. my file.location /opt/lampp/phpmyadmin

$cfg['blowfish_secret'] = '$5hfhjfhgst5fg4%43(*&'; /* YOU SHOULD CHANGE THIS FOR A     MORE SECURE COOKIE AUTH! */

/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'wtf11111';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
//$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysql if your server does not have mysqli */
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true;

In my.cnf located in /etc/mysql/my.cnf

port        = 3306
socket      = /var/run/mysqld/mysqld.sock

[mysqld_safe] socket = /var/run/mysqld/mysqld.sock nice = 0

[mysqld] # # * Basic Settings # user = mysql pid-file = /var/run/mysqld/ socket = /var/run/mysqld/mysqld.sock port = 3306 basedir = /usr datadir = /var/lib/mysql tmpdir = /tmp lc-messages-dir = /usr/share/mysql skip-external-locking

share|improve this answer

You can reset the password for the MySQL by login to the safe mode.

Stop the MySQL service by using the below command.

/etc/init.d/mysql stop

Then start the MySQL using in the safe mode

mysqld_safe --skip-grant-tables

Once login to the MySQL using the safe mode, please execute the below command to update the password.

UPDATE user SET Password=password('MySQL_PWD') WHERE User='root'; FLUSH PRIVILEGES;


After executing the above command kill the mysqld and start the MySQL.

Now try login to the MySQL with the updated password.

share|improve this answer


/opt/lampp/bin/mysql -u root

and then use

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword');

to set your password and then use ctrl + c or use exit to logout from mysql then use

/opt/lampp/bin/mysql -u root -p

and type password (password is hidden ) and ENTER then enjoy

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.