# phpmyadmin + mysql won't connect.

## Koenpje

I have emerged Apache2 + mod_php + phpmyadmin + mysql + phpBB

I configured mod_php so apache2 already can handle php and it works perfect. Now I wanted to install phpBB, I runned the install.php file but you needed a database first. I tought that phpmyadmin was a progam to create and manage mysql databases? 

When I try to connect to 192.168.1.4/phpmyadmin I get a log-in screen, but whatever I try, I can't get any access... Then I went to the config.inc.php file and checked the username and password, but still I can't get access, then I setted auth_type to config instead of http, and now I don't need to log-in, he just gives me:

```

Welkom op phpMyAdmin 2.6.1-pl2

phpMyAdmin probeerde met de MySQL server te verbinden maar de server weigerde de verbinding. Controleer de host, de gebruikersnaam en het wachtwoord in config.inc.php en zorg er voor dat deze overeenkomen met de informatie die u van de Beheerder van de MySQL server kreeg.

Fout

MySQL retourneerde: Documentatie

#2013 - Lost connection to MySQL server during query

```

I know it is in dutch, I will translate a bit:

```

Welcome on phpMyAdmin 2.6.1-pl2

phpMyAdmin tryed to connect with the MySQL server but the server refused the connection. Check the host, username and the password in the config.inc.php file en make sure that they are the same from the info you got from the administrator of the MySQL server.

Error

MySQL returned: Documentation

#2013 - Lost Conection to MySQL server during query

```

But I checked my host and username and password in the config.inc.php file, and I've been trying for hours now..

----------

## adaptr

 *Koenpje wrote:*   

> I have emerged Apache2 + mod_php + phpmyadmin + mysql + phpBB
> 
> I configured mod_php so apache2 already can handle php

 

Not necessary - all you need to do (in fact all you should do) is add "-D PHP4" to /etc/conf.d/apache2.

 *Koenpje wrote:*   

>  and it works perfect. Now I wanted to install phpBB, I runned the install.php file but you needed a database first. I tought that phpmyadmin was a progam to create and manage mysql databases? 

 

Yes and no - phpmyadmin is a web interface to administer a MySQL server.

 *Koenpje wrote:*   

> When I try to connect to 192.168.1.4/phpmyadmin I get a log-in screen, but whatever I try, I can't get any access...

 

You must set a user and password first; for full access to mysql this has to be the mysql root user (which has nothing to do with the system root user!)

For now, leave the php config files alone; just verify that you can use mysql:

```
mysql
```

It should drop you to a mysql command shell as root, who by default has no password.

If this works, exit the mysql cmdline and type:

```
mysqladmin -u root password <type password to use>
```

If this succeeds then you have a user and password you can use for phpmyadmin.

Now enter these values into config.inc.php and reload the page.

If you messed up the config beyond hope just emerge phpmyadmin first.

man mysql, man mysqladmin and carefully read the docs for phpmyadmin - it's quite a complicated little program!

----------

## Koenpje

I can run "mysql" and then I did:

```

mysqladmin -u root password koen

```

I entered it into the config.inc.php file but still the same  :Sad:   When I have auth_type=config I don't need to log in and when I set http as auth_type I get a inlog screen but nothing works to log in  :Crying or Very sad: 

Both ways --> #2013 - Lost Conection to MySQL server during query

----------

## c4

When I setup PMA I just leave the config.inc.php alone, I would not consider putting my root pass to mysql in there anyway. Instead just use the http auth_type and try logging in as root with a blank pass, even if you have set a pass earlier for root. Phpmyadmin should verify your access with the controlluser, so if you have remerged PMA or re-run the pma-database setup these values might be in error.

Once you get into phpmyadmin you may set your root pass. and remove test users etc. and than set $cfg['PmaAbsoluteUri'] in the config.inc.php file.

There's a good PMA guide here. It's in Swedish, though you will recognise the pictures so it might be of some help.

A wise thing to do is set limits in who may access phpmyadmin. Use at least auth_type basic or allow only from your_ip, combined with ssl etc. in your apache sonfiguration. There are tons of kiddies scanning and trying to access  your mysql through phpmyadmin, make sure they don't succeed.

----------

## Koenpje

PMA? I can't find PMA as a ebuild. And I can't lo-gin as PMA also.

I've tried everything, even re-emerged Mysql, but still the same problem:

- Auth_type = config --> I don't need to log - in. I get immediately the welcome screen and the error:  #2013 - Lost Conection to MySQL server during query

- Auth_type = http --> I can't log-in, whatever I try, whatever I set as username and password in the config.inc.php file or when I do this: mysqladmin -u root password koen

- When I typed "Mysql" it works perfect, but now, after I set the password with mysqladmin -u root password koen, I get this fault:

```

tux root # mysql

ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)

```

----------

## c4

 *Koenpje wrote:*   

> PMA? I can't find PMA as a ebuild. And I can't lo-gin as PMA also.

 

I was using the abbreviation PMA instead of writing 'phpMyAdmin'. Sorry for the confusion.

As it seems to be a troublesum issue getting phpMyAdmin running, I decided to write my own guide how to install and to give a bit additional security to phpMyAdmin once it has been installed. 

The guide for phpMyAdmin, in english.

----------

## dojobi

c4 - thank you so much! That is the best PMA guide on the whole Internet. I've been trying for hours to get it up and running. I followed the steps in the guide and within minutes I was up and running.

Cheers,

Michael

----------

## c4

 *dojobi wrote:*   

> c4 - thank you so much! That is the best PMA guide on the whole Internet. I've been trying for hours to get it up and running. I followed the steps in the guide and within minutes I was up and running.
> 
> Cheers,
> 
> Michael

 

You're welcome Michael, glad it came to use  :Wink: 

----------

## manzanares

 *c4 wrote:*   

>  *dojobi wrote:*   c4 - thank you so much! That is the best PMA guide on the whole Internet. I've been trying for hours to get it up and running. I followed the steps in the guide and within minutes I was up and running.
> 
> Cheers,
> 
> Michael 
> ...

 

Micheal, I agree with Dojobi: Great post ! Thank you.

Manzanares.

----------

## Peach

 *c4 wrote:*   

> The guide for phpMyAdmin, in english.

 

great guide, thanks  :Smile: 

----------

## iwalmsley

I tried using the guide, as I was pleased with it's format but I am still getting this error

```
atlas mysql # mysql -u root

ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)

```

Any suggestions?

----------

## c4

 *iwalmsley wrote:*   

> atlas mysql # mysql -u root
> 
> ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)
> 
> 

 

Did you have mysql setup since earlier ? If you have a brand new install of mysql, the default password for (mysql)root is <null>  (empty password). But once a password is set, you need to pass it to mysql when connecting, eg 

```
mysql -u root -p
```

 and type your password when prompted.

But if you have just emerged mysql and got the grant tables up + started mysql you should be able to connect with the command you where using. Have you tried to rebuild the grant tables? Please provide some more information about your setup, as depending on your setup, there are different approaches to how you should solve your problem.

----------

## iwalmsley

I type:

atlas / # mysql -u root

I still get:

ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)

When I type:

atlas / # mysql -u root -p

Enter password:

And type the password 'type85' it allows me to see this:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 44 to server version: 4.0.24

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

(the password 'type83' is what I assigned the root user in one of my steps I've tried.)

Well about my setup, it's a Gentoo 2005.0 Install, it's my 2nd Gentoo Server. Running on this machine is apache, php4, mysql, phpmyadmin, phpsysinfo, ngircd (IRC Server), and jabberd. My problems are comming from linking phpmyadmin to mysql I beleive. I do not know of anyother way to test SQL for access, as I have not gotten further that this step I am stuck on.

and now when I direct my browser to /phpmyadmin I get a blank page and no login prompt.

----------

## c4

OK, I was thinking in terms of if you had a new install of mysql etc. Anyway, you can connect to mysql as root so that's great! 

I guess the easiest way to solve your pmpMyAdmin problems are to do the following:

Try these steps as root: Look in 

```
/var/lib/mysql/
```

 and see if you have your phpMyAdmin database there, on my box it's called pmadb.

If you have something like pmadb there, delete it. Do the same for your phpmyadmin directory in htdocs. The reason for deleting these two directories are you are likely to get problems when connecting to mysql, with your 'old' pma-controll user.

```
rm -r /var/lib/mysql/pmadb

rm -r /var/www/localhost/htdocs/phpmyadmin
```

Next, emerge phpmyadmin again. When it's done you will be at step #2 of the guide  and you should see the output of prompting you to add your phpmyadmin-database to mysql.

What happened during the new emerge, was a new random password was created for 'the pma controll user' that will match the new phpmyadmin database. So by removing the old stuff and making a 'clean' install of phpmyadmin you should be able to continue. Remeber to follow the output on your screen after emerging phpmyadmin, as the paths in that guide (step #2) that I wrote are old and probably don't apply anymore.

So when doing this part 

```
mysql -u root -p < /usr/share/webapps/phpmyadmin/2.6.1_p2-r1/sqlscripts/mysql/2.6.1_p2-r1_create.sql
```

 but using the right path, you just enter your mysql-root pass when asked (type83) and it should install the database for you. Once inside phpMyAdmin you can easily change your rootpass again. Remember to also set up some kind of limitation to the phpMyAdmin directory in htdocs. Se some further information in the guide.

----------

## frameRATE

great guide, man!

----------

## Alex Ludd

You need to allow localhost root access to 127.0.0.1 and then login to that ip instead of 192.168.1.4.

If that doesn't work, check to see if your isp or your firewall is blocking port 80 or 8080.

----------

## iwalmsley

hallelujah! That last post from C4 worked. I appreciate it!

----------

## Joseph_sys

 *c4 wrote:*   

>  *Koenpje wrote:*   PMA? I can't find PMA as a ebuild. And I can't lo-gin as PMA also. 
> 
> The guide for phpMyAdmin, in english.

 

Your instructions are the best, thank you for such an excellent web-page tutorial.

----------

