# can't login to mysql [solved]

## dundas

Dear all:

        I emerged mysql time ago without configuring it, today after I emerge world, I try to initialize the mysql database by following

http://dev.gentoo.org/~chriswhite/mysql.html

        However during the step of 

```
# /etc/init.d/mysql start

 * Re-caching dependency info (mtimes differ)...

 * Starting mysqld (/etc/mysql/my.cnf) ...

 * [ ok ] 

$ /usr/bin/mysqladmin -u root -h localhost password 'new-password'
```

         I can start the init.d but then I got

```
# /usr/bin/mysqladmin -u root -h 127.0.0.1 password 'new-password'

/usr/bin/mysqladmin: connect to server at '127.0.0.1' failed

error: 'Access denied for user: 'root@localhost' (Using password: NO)'
```

          If I add -p to the end of that command, I got

```
/usr/bin/mysqladmin -u root -h 127.0.0.1 password 'new-password' -p

Enter password:

/usr/bin/mysqladmin: connect to server at '127.0.0.1' failed

error: 'Access denied for user: 'root@localhost' (Using password: YES)'
```

I tried several passwords, including "mysql", but they dont work, so I'm afraid either I forgot the password I set or I did sometihng wrong configuring it.

would u please instruct me either, how to reset the password, or how to correct this problem?

thank you sir!

----------

## ikaro

if you put the password inside ' ' then thats part of the password.

usually just using -u root -p -h localhost password Password  works.

try to login putting your password inside ' '

----------

## dundas

[EDIT], the mysqladmin command I used below is like a login script or is it used to set the password? 

 *ikaro wrote:*   

> if you put the password inside ' ' then thats part of the password.
> 
> usually just using -u root -p -h localhost password Password  works.
> 
> try to login putting your password inside ' '

 

okey ikaro, thx for replying so quick!

I unmerged mysql and emerged it again,

then I start the init.d and try to run

```
/usr/bin/mysqladmin -u root -h localhost password 'myownpasswordhere'
```

and I got same output:

```
connect to server at 'localhost' failed

error: 'Access denied for user: 'root@localhost' (Using password: NO)
```

any ideas? thx

----------

## ikaro

read the messages from the ebuild - you need to run some commands to create the first db.

after you start the server, and change the password after.

----------

## dundas

yes I did read the ebuild and followed every step it outputs 

```
* MySQL DATADIR is /var/lib/mysql

 *

 * You might want to run:

 * "ebuild /var/db/pkg/dev-db/mysql-4.0.24/mysql-4.0.24.ebuild config"

 * if this is a new install.

 *

 *

 * If you're upgrading from MySQL-3.x to 4.0, or 4.0.x to 4.1.x, you

 * must recompile the other packages on your system that link with

 * libmysqlclient after the upgrade completes.  To obtain such a list

 * of packages for your system, you may use 'revdep-rebuild' from

 * app-portage/gentoolkit.

 *

 * InnoDB support is not selected to be compiled in.
```

# ebuild /var/db/pkg/dev-db/mysql-4.0.24/mysql-4.0.24.ebuild config

 * MySQL DATADIR is /var/lib/mysql

 * Hmm, it appears as though you already have the mysql

 * database in place.  If you are having problems trying

 * to start mysqld, perhaps you need to manually run

 * /usr/bin/mysql_install_db and/or check your config

 * file(s) and/or database(s) and/or logfile(s).

and

```
 *

 * You might want to run:

 * "ebuild /var/db/pkg/dev-db/mysql-4.0.24/mysql-4.0.24.ebuild config"

 * if this is a new install.

 *

 *

 * If you're upgrading from MySQL-3.x to 4.0, or 4.0.x to 4.1.x, you

 * must recompile the other packages on your system that link with

 * libmysqlclient after the upgrade completes.  To obtain such a list

 * of packages for your system, you may use 'revdep-rebuild' from

 * app-portage/gentoolkit.

 *

 * InnoDB support is not selected to be compiled in.
```

# ebuild /var/db/pkg/dev-db/mysql-4.0.24/mysql-4.0.24.ebuild config

 * MySQL DATADIR is /var/lib/mysql

 * Hmm, it appears as though you already have the mysql

 * database in place.  If you are having problems trying

 * to start mysqld, perhaps you need to manually run

 * /usr/bin/mysql_install_db and/or check your config

 * file(s) and/or database(s) and/or logfile(s).[/code]

till I got this

```
# /usr/bin/mysql_install_db

WARNING: The host 'sailsail' could not be looked up with resolveip.

This probably means that your libc libraries are not 100 % compatible

with this binary MySQL version. The MySQL daemon, mysqld, should work

normally with the exception that host name resolving will not work.

This means that you should use IP addresses instead of hostnames

when specifying MySQL privileges !

Installing all prepared tables

To start mysqld at boot time you have to copy support-files/mysql.server

to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !

To do so, issue the following commands to start the server

and change the applicable passwords:

  /etc/init.d/mysql start

  /usr/bin/mysqladmin -u root -h sailsail password 'new-password'

  /usr/bin/mysqladmin -u root password 'new-password'

Depending on your configuration, a -p option may be needed

in the last command. See the manual for more details.

NOTE:  If you are upgrading from a MySQL <= 3.22.10 you should run

the /usr/bin/mysql_fix_privilege_tables. Otherwise you will not be

able to use the new GRANT command!

You can start the MySQL daemon with:

cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:

cd sql-bench ; perl run-all-tests

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at

http://www.mysql.com

Support MySQL by buying support/licenses at https://order.mysql.com
```

another quesition, which might lead to the problem, do I have to add "innodb" into the USE flags in my make.conf? I thought I didn't need it since it's marked blue below

```
# emerge -pvND mysql

These are the packages that I would merge, in order:

Calculating dependencies ...done!

[ebuild   R   ] dev-db/mysql-4.0.24  +berkdb -debug -innodb +perl +readline (-selinux) +ssl -static +tcpd 0 kB
```

sorry I'm completely new to mysql under linux

----------

## ikaro

uff....

/usr/bin/mysqladmin -u root -h 127.0.0.1 password new-password

/usr/bin/mysqladmin -u root password new-password 

does this works ?

----------

## dundas

hi man, here is the output, after I start init.d for mysql.

```
# /usr/bin/mysqladmin -u root -h 127.0.0.1 password [mypasswordherewithtout'']

/usr/bin/mysqladmin: connect to server at '127.0.0.1' failed

error: 'Access denied for user: 'root@localhost' (Using password: NO)
```

thx

----------

## ikaro

try adding -p also.

----------

## dundas

Hi ikaro, thx for helping along

I followed this guide 

http://dev.mysql.com/doc/mysql/en/resetting-permissions.html

to reset the password, and I could do the

```
# /usr/bin/mysqladmin -u root password 'mypasswordinside' -p

Enter password:

# 
```

without problems, however, to make sure things are right, I try to do the test in the directory of /usr/share/mysql/sql-bench

```
# perl run-all-tests

Got error: 'Access denied for user: 'root@localhost' (Using password: NO)' when connecting to DBI:mysql:database=test;host=localhost with user: '' password: ''
```

Any comments?

----------

## dundas

Just to let you know, that this worked now! so I'll call this thread solved.

 :Razz:   :Razz:   :Razz:  thx buddy.

```
# mysql -u root -p

Enter password:

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

Your MySQL connection id is 4 to server version: 4.0.24

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

mysql> 
```

only thing not sure is about the run-all-tests.

----------

## ikaro

Oh it works - cool  :Cool: 

 *ikaro wrote:*   

> Im not mysql expert - far from it, however, i dont think it needs much expertise in seeing that possibly two things are wrong;
> 
> in your installation something went wrong/ your didnt follow the steps in the right order and something got messed up
> 
> OR
> ...

 

----------

## dundas

yes, I believe so, either I created the initial database wiz some other password, or I messed up wiz the steps some time ago.

you did assist me to troubleshoot the source of the prob. And yes I would try to clear up all the users and database before my next clean install (I wonder why emerge -CvND mysql didn't do that) for God's sake.

thank you  :Smile: 

----------

