phpMyAdmin is throwing a #2002 cannot log in to the mysql server phpmyadmin
I have installed MySQL server enterprise 5.1 on my local machine and now I want to install phpMyAdmin, but it does not work.
I have unrared phpMyAdmin to my server root directory and browsed to "localhost/phpMyAdmin/setup/index.php", started a new server and the only setting I changed was filling in my MySQL password in the field "Password for config auth"
So now when I am trying to log in I get an error message saying "#2002 cannot log in to the mysql server phpmyadmin"
Does anyone know what's wrong? I've been having this problem si开发者_StackOverflow社区nce yesterday.
If you're getting the #2002 Cannot log in to the MySQL server
error while logging in to phpmyadmin, try editing phpmyadmin/config.inc.php
and change:
$cfg['Servers'][$i]['host'] = 'localhost';
to:
$cfg['Servers'][$i]['host'] = '127.0.0.1';
Solution from Ryan's blog
Edit (20-Mar-2015):
Note that if you're on a fresh install, config.inc.php may not exist. You need to rename / copy config.sample.inc.php and then change the relevant line
This is old but as it is the first result in Google,
Please note that this also happens when your MySql service is down,
I fixed this by simply restarting MySQL Server using:
/etc/init.d/mysql restart
in SSH (Command is for a CentOS/CPanel server)
Background: I am using Linux Mint 13. In my case, this error happened when I restarted the computer and my DHCP assigned a new local IP address (from 192.168.0.2 to 192.168.0.4) to my desktop.
sudo gedit /etc/mysql/my.cnf
Update
bind-address = 192.168.0.2
to
bind-address = localhost
This fixed the problem. Enjoy.
This can also be caused if you forget (as I did) to move config.inc.php
into its proper place after completing the setup script.
After making the config
folder and doing chmod o+rw config
and going to localhost/phpmyadmin/setup
and following those steps, you need to go back to the command line and finish things off:
mv config/config.inc.php . # move file to current directory
chmod o-rw config.inc.php # remove world read and write permissions
rm -rf config # remove not needed directory
See full instructions at https://phpmyadmin.readthedocs.org/en/latest/setup.html
After trying all of the above suggestions here is what fixed my #2002 error.
Add the following line to your config.inc.php file and change the number to your MySQL port:
$cfg['Servers'][$i]['port'] = '3307'; // MySQL port
I had multiple mysql instances installed, and in this case, I had updated my.ini to run MySQL on port 3307, but had not updated phpMyAdmin to reflect the new port. In my case, the line for the port did not exist in the config.inc.php file, so I was not aware that it needed updating.
Did you set up the MySQL on your machine? It sounds like you're using Windows; MySQL runs as a "Service" on your machine (right-click My Computer -> Manage -> Services).
I've been through basically all of stackoverflow for this error and nothing resolved my issue. I was able to log into mysql directly from the linux command line fine, but with the same user and password couldn't log into phpmyadmin.
So I beat my head against the wall for half the day until I realized it wasn't even reading the config.inc.php under /etc/phpmyadmin (the only place it was located btw based on "find / -iname config.inc.php". So I changed the host in /usr/share/phpMyAdmin/libraries/config.default.php and it finally worked.
I know there's probably another issue with why it isn't reading the config from the /etc/phpmyadmin folder but I can't be bothered with that for now :P
tldr; if your settings don't seem to be applying at all try making the changes within /usr/share/phpMyAdmin/libraries/config.default.php
I have also experienced the same thing, hopefully a this helps.
cd /etc/init.d
./mysql start
please login to access mysql and phpmyadmin
It happened with me when I changed the instance type of my AWS server.
#2002 Cannot log in to the MySQL server
can also occur when the mysqld
service is not started.
So first of all you need to execute :
$ sudo service mysqld restart
This will give you :
$ sudo service mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
After that the error will not come.
P.S. On EC2 instances, one should also change the host from localhost
to 127.0.0.1
as mentioned in the top answer.
- Right-click My Computer -> Manage -> Services
- Choose "Services" under the "Services and Application" from right pane
- Then search for the "Zend Development" Service.
- When you find it, double click to start that service.
Now, you should be able log in to phpMyAdmin.
I had same issue after the server has been attacked using a DDoS (actually a penetration testing tool).
I've headed to /etc/var/mysql/error.log first to see the InnoDB had a file lock.
The issue was immediately fixed by restarting the server, however that's not future-proof.
In my system, config.inc.php
didn't exist, but config.sample.inc.php
existed. Try copying the sample script to config.inc.php
Had this problem a number of times on our setup, so I've made a check list.
This assumes you want phpMyAdmin connecting locally to MySQL using a UNIX socket rather than TCP/IP.
UNIX sockets should be slightly faster as they have less overhead and can be more secure as they can only be accessed locally.
Service
- Is the mysqld service running?
service mysqld status
- .. If not
service mysqld start
- Has config has changed since service started?
service mysqld restart
MySQL Config (my.cnf)
- Check that there isn't a non-socket client protocol set, e.g.
protocol=tcp
- Check that the socket location is accessible and has the right permissions
PHP Config (php.ini)
If you can connect locally from the command line, but not from phpMyAdmin, and the socket file is not in the default location:
- Set the mysqli default sockets to the new location:
mysqli.default_socket = *location*
- ... I also set the
pdo_myql.default_socket
andmysql.default_socket
just to be sure - Restart your web service (httpd in my case)
service httpd restart
phpMyAdmin Config (config.inc.php)
- Check that the host is set to localhost:
$cfg['Servers'][$i]['host'] = 'localhost';
- The socket location can also be set here:
$cfg['Servers'][$i]['socket'] = '*location*';
N.B.
As pointed out by @chk; Setting the $cfg['Servers'][$i]['host']
from localhost
to 127.0.0.1
just causes the connection to use TCP/IP rather than using the socket and is more of a workaround than a solution.
The MySQL config setting bind-address=
also only affects TCP/IP connections.
If you don't need remote connections, it is recommended to turn off TCP/IP listening with skip-networking
.
For Ubuntu 14.04 and 16.04, you can apply following commands
First, check MySQL service is running or not using
sudo service mysql status
Now you can see you show a message like this: mysql stop/waiting.
Now apply command: sudo service mysql restart!
Now you can see you show a message like this: mysql start/running, process 8313.
Now go to the browser and logged in as root(username) and root(password) and you will be logged in successfully
In ubuntu OS in '/etc/php5/apache2/php.ini' file do configurations that this page said.
For those who get this error when working with WAMP/XAMP on a windows machine.
This may help you.
Your solution is to
- net stop mysql
- Erase binary logs (and the binary log index file)
- IF you do not know where they are, locate my.ini on your PC
- Open my.ini in Notepad look for the option log-bin or log_bin
- Look for the option datadir
- If log-bin only has a filename, look inside the folder specified by datadir
- If log-bin includes a path and a filename, look inside the folder specified by log-bin
- Open the desired folder in Windows Explorer
- Remove the binary logs There should be a file whose file extension is .index. Delete this as well net start mysql
Please DO NOT ERASE ib_logfile0 or ib_logfile1 when you have binary log issues.
Answer is on dba.stackexchange
CAUTION: This method completely removes MySQL data!
I have same problem in Ubuntu 12.10 , mysql 5.5
I have tested lots of answer related to my issue but none of theme work
at last I had to reinstall remove my mysql server completely and then I install again Mysql server
but you should be aware that you should delete all directory which related to Mysql I use this link to remove mysql completely
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
sudo deluser mysql
sudo rm -rf /var/lib/mysql
sudo rm -rf /etc/mysql
sudo rm -rf /var/lib/mysql
sudo rm -rf /var/run/mysqld
and then you install again LAMP by tasksel
Removing MySQL 5.5 Completely
https://serverfault.com/questions/254629/unable-to-install-mysql-server-in-ubuntu/296928#296928
After Many attempts in getting this fixed, it was found out that the issue was with Mysql users not being allowed to login
netstat -na | grep -i 3306
If it is listening on all interfaces, then you can assign any of your interfaces to this
$cfg['Servers'][$i]['host'] = 'ANY INTERFACE';
Try to Login using the above IP using the comand line
mysql -u bla -p -h <Above_IP_address>
If this works then your phpmyadmin will also work, If not fix the mysql.user table so that the above command works and allows you to login to mysql.
Right-click My Computer -> Manage -> Services Choose "Services" under the "Services and Application" from right pane Then search for the "mysql" Service. When you find it, double click to start that service.
Now you should be able to run and login to PhpMyAdmin
Check whether you server is running or not.
It is because your system has two installations of "mysql" packages. One installation was made through xampp/lampp and another installation was made through mysql-debain package. To solve the problem, just go to "synaptic manager" and remove mysql, and then you will be able to access mysql from xampp server.
Note : removing mysql from synaptic manager doesn't affect mysql which was installed through xampp/lampp server. So don't worry!
Just in case anyone has anymore troubles, this is a pretty sure fix.
check your etc/hosts file make sure you have a root user for every host.
i.e.
127.0.0.1 home.dev
localhost home.dev
Therefore I will have 2 or more users as root for mysql:
root@localhost
root@home.dev
this is how I fixed my problem.
For me the problem was solved by deleting a .pid file named after my computer:
sudo rm /var/mysql/computername.pid
This the following line in your php.ini file
mysql.default_socket = "MySQL"
to
mysql.default_socket = /var/run/mysqld/mysqld.sock
This problem occurs when you already had MySQL installed on your machine or in case you have changed the post number of the MySql service which is 3306(Default). In order to solve this, you have to tell the phpMyAdmin to look for another port instead of 3306. To do so go to C:\xampp\phpMyAdmin(default location) and open Config.inc
and add this line $cfg['Servers'][$i]['port'] = '3307';
after $cfg['Servers'][$i]['AllowNoPassword'] = true;
Restart the services and now it should work.
I had an issue with the path of the MySQL service in the Windows 7 registry which was not changed with the new installed XAMPP or newer easyPHP version.
So if anybody has the same problem (#2002 error, phpMyAdmin cannot be started) you can search into the win regedit for 'my.ini' and exchange the path to the new package.
For example I exchanged on a few places the older path:
C:\EASYPH~1.1VC\binaries\mysql\bin\eds-mysqld.exe --defaults-file=C:\EASYPH~1.1VC\binaries\mysql\my.ini MySQL
with the newer one:
c:\xampp\mysql\bin\mysqld.exe --defaults-file=c:\xampp\mysql\bin\my.ini mysql
It is strange that nobody described this issue before on the web!
my problem is solved by this step
- apt-get install mysql-server phpmy admin
- /etc/init.d/mysql restart
- done.
精彩评论