# mysql and phpmyadmin: Access Denied -- no web login

## iwalmsley

I've tried every post I can find and nothing works.  I didn't want to start another thread, but here goes. I'm getting this error:

@localhost permission denied.

like in:

https://forums.gentoo.org/viewtopic-t-320895-highlight-mysql+denied.html

then I try this stuff:

atlas mysql # mysql -u root

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

Your MySQL connection id is 1 to server version: 4.0.24

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

mysql> SET PASSWORD FOR ''@'localhost' = PASSWORD('qpzm81');

ERROR 1132: You must have privileges to update tables in the mysql database to be able to change passwords for others

I've tried:

atlas mysql # mysql -u root@atlas

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

Your MySQL connection id is 4 to server version: 4.0.24-log

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

mysql> use mysql;

ERROR 1044: Access denied for user: '@localhost' to database 'mysql'

mysql>

So know Access is denied for any mysql command.

I can't login via phpmyadmin

I just did a unmerged mwsql and phpmyadmin and emerged them again, followed this HOTO: http://arcticalliance.se/pma.htm STILL same thing:

ERROR 1044: Access denied for user: '@localhost' PASSWORD (NO)

I figured I could do what is suggested and like the other posts I try them and I have same or different errors. I've asked around I am looking for a solution. Thanks alot!

----------

## keli

You must set up some user both for mysql and for phpmyadmin. You can use root user as well, but right now it seems, you're using NO user for phpmyadmin. To change that, look into phpmyadmin's config file. (config.inc.php)

To add a new user to mysql, you can use:

```
grant all on database.* to username@localhost identified by 'password';
```

----------

## minskpower

This is a maybe:

PMA when emerged configures itself with a user pma and some random password for facilities like bookmarks, pdf and some others. You can find it in config.inc.php first entry in the $servers array. If you can't be bothered to add the PMA user and password to mysql just blank the values to disable those features, but don't forget those tables lower beginning with PMA_, you'll have to unset them too for this to work.

Below the pma user is the root user and password, set them, change auth type to config and see if it works, if it does change back to your preffered auth type.

----------

## jonnevers

 *iwalmsley wrote:*   

> I've tried every post I can find and nothing works.  I didn't want to start another thread, but here goes. I'm getting this error:
> 
> @localhost permission denied.
> 
> like in:
> ...

 

This is a little confusing, so I apologize if I am off base

first off, if you are logging into mysql from the command line the syntax is

```
 # mysql -u username -p
```

the -p flag tells the mysql client that you are going to be suppling a password. if you don't use that flag and the account has a password it will always tell you 'authentication failed (using password=NO)', the password=NO part is the telling part.

your password command and grant commands also look a bit off

reference: http://dev.mysql.com/doc/mysql/en/adding-users.html

I've maintained my mysql db for about 4 years now. I highly recommend adding a user account (normal name) that has all the privileges of root then remove the root user account. the root account has no particuliar meaning inside the database and can be safely removed assuming another user account is given the same grant privileges. This is a security precaution.

OH and do not forget that when you do succesfully update the mysql.user database table that the changes are not automatically available. you must manually execute the SQL statement

```
 mysql > flush privileges;
```

that will cause the daemon to reinitialize it's privileges based on the user table changes.

- Jon

----------

## iwalmsley

run this command:

grant all on database.* to username@localhost identified by 'password';

get this error:

ERROR 1064: You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near 'database.* to username@localhost identified by 'password'' at l

---

since my last post, I unemerged mysql and phpmyadmin, removed the .conf files and directories. Remerged mysql only as the HOWTO I mentioned prior. I have not changed any files. The only thing I have tried except for mentions on this tread is when I go this command:

atlas / # mysql -u root@atlas

I get into mysql and it looks like this.

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

Your MySQL connection id is 17 to server version: 4.0.24

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

mysql>

BUT, if I continue the howto, I get this:

mysql> SET PASSWORD FOR ''@'localhost' = PASSWORD('set_password');

ERROR 1044: Access denied for user: '@localhost' to database 'mysql'

I cannot go any further and no other posts have helped in my situation. I want to use this combination with a passion and would appreciate any more suggestions. I will do and report back. Thanks! Thanks!

----------

## keli

sorry, if I wasn't explicit enough. That command was only a generic one, and "database", "user" and "password" should have been replaced with appropriate values.

But to get pma up and running, just look for config.inc.php (it should be located at /var/www/localhost/htdocs/phpmyadmin or something like that), edit it, and look for these lines:

```

$cfg['Servers'][$i]['auth_type']     = 'config';    // Authentication method (config, http or cookie based)?

$cfg['Servers'][$i]['user']          = 'root';      // MySQL user

$cfg['Servers'][$i]['password']      = '';          // MySQL password 
```

The values might be different, but you can set them up as above. This will give you a basic (and not too secure) pma setup.

----------

## iwalmsley

Ok, I posted what you typed not what I typed I replaced the appropriate values for the information on my server.

I still get that error. I also tried changing the config file (again this is all fresh) i have done this before, but in different orders, after changing the information in the config file, now I get this in the web browser:

phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in config.inc.php and make sure that they correspond to the information given by the administrator of the MySQL server.

----------

## iwalmsley

This is in the config.inc.php file (just the Server(s) Config part:

```
 * Server(s) configuration

 */

$i = 0;

// The $cfg['Servers'] array starts with $cfg['Servers'][1].  Do not use $cfg['Servers'][0].

// You can disable a server config entry by setting host to ''.

$i++;

$cfg['Servers'][$i]['host']          = 'localhost'; // MySQL hostname or IP address

$cfg['Servers'][$i]['port']          = '';          // MySQL port - leave blank for default port

$cfg['Servers'][$i]['socket']        = '';          // Path to the socket - leave blank for default socket

$cfg['Servers'][$i]['connect_type']  = 'tcp';       // How to connect to MySQL server ('tcp' or 'socket')

$cfg['Servers'][$i]['extension']     = 'mysql';     // The php MySQL extension to use ('mysql' or 'mysqli')

$cfg['Servers'][$i]['compress']      = FALSE;       // Use compressed protocol for the MySQL connection

                                                    // (requires PHP >= 4.3.0)

$cfg['Servers'][$i]['controluser']   = 'pma';       // MySQL control user settings

                                                    // (this user must have read-only

$cfg['Servers'][$i]['controlpass']   = '764868441530315778';

                                                    // access to the "mysql/user"

                                                    // and "mysql/db" tables).

                                                    // The controluser is also

                                                    // used for all relational

                                                    // features (pmadb)

$cfg['Servers'][$i]['auth_type']     = 'config';      // Authentication method (config, http or cookie based)?

$cfg['Servers'][$i]['user']          = 'root';      // MySQL user

$cfg['Servers'][$i]['password']      = 'iv1012zm';          // MySQL password (only needed

                                                    // with 'config' auth_type)

$cfg['Servers'][$i]['only_db']       = '';          // If set to a db-name, only

                                                    // this db is displayed in left frame

                                                    // It may also be an array of db-names, where sorting order is relevan$

$cfg['Servers'][$i]['verbose']       = '';          // Verbose name for this host - leave blank to show the hostname

$cfg['Servers'][$i]['pmadb']         = 'pmadb';     // Database used for Relation, Bookmark and PDF Features

                                                    // (see scripts/create_tables.sql)

                                                    //   - leave blank for no support

                                                    //     DEFAULT: 'phpmyadmin'

```

----------

## minskpower

this version of myadmin comes with pma facilities like bookmarks pdf and other stuff I don't use by default.

two ways of getting rid of user unknown errors.

1. add the pma user and his random weird looking password generated by the install script to database mysql table user or

2. delete any string for user pma, his password, and all references below to PMA_ tables to not use them features if you can't be bothered to do 1. just leave empty strings.

I have posted this yesterday if you look above.

----------

## iwalmsley

I've tried everything that has been posted in this thread. I am still having troubles. Same issue. it will not let me in. non phpmyadmin, just shell access. none of the howto's have provided any additional options. I've tried everything I've read.

----------

