Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 78739 - MySQL Requires no password (4.0.22)
Summary: MySQL Requires no password (4.0.22)
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Gentoo Linux MySQL bugs team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-19 15:03 UTC by C J Pro
Modified: 2005-01-21 19:18 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description C J Pro 2005-01-19 15:03:36 UTC
I have tried this on both 2004.3 and 2004.2 and both versions of gentoo experience the same problems (latest gentoo-dev-source).

I have created a user on MySQL with a password set.  When I go to log in as the user with mysql -u user -p, it won't let me log in until I remove the -p.  I've tried restarting mysql, reemerging it, clearing the databases, and the basic flush privileges and nothing seems to work.

I also cannot connect to MySQL from a remote client (no firewall, so port 3306 is open for mysql).
Comment 1 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2005-01-19 17:10:33 UTC
Is is prompting you for the password?

How did you create the user?


Could you please run this statement and provide me with the result?
"SELECT * FROM mysql.user WHERE user='yourusernamehere';"
(put in the correct username).

The hash of the password should be there.
Comment 2 C J Pro 2005-01-19 17:31:32 UTC
-----+-----------------+------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+
| Host | User    | Password         | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Show_db_priv | Super_priv | Create_tmp_table_priv | Lock_tables_priv | Execute_priv | Repl_slave_priv | Repl_client_priv | ssl_type | ssl_cipher | x509_issuer | x509_subject | max_questions | max_updates | max_connections |
+------+---------+------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+
| %    | C_J_Pro | 74<not posting full hash> | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y       | Y            | Y         | Y          | Y               | Y          | Y          | Y            | Y          | Y  | Y                | Y            | Y               | Y                |          |            |             |              |             0 |           0 |               0 |
+------+---------+------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+
Comment 3 C J Pro 2005-01-19 17:32:54 UTC
O yea, forgot.  I created the user with the GRANT ALL PERMISSION ON *.* ... command.  The password hash is there.
Comment 4 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2005-01-19 17:52:41 UTC
What's the full command you used?
the mysql command line client does keep history across sessions, so it should be easy to find.

also,
run "SELECT PASSWORD('yourpasswordhere');"
and see if returns the same value as the hash from the SELECT.

As for connecting from other machines, see the my.cnf file, and take out the 'bind-address    = 127.0.0.1' statement if you need to connect from another machine.

If the password hashes don't match, then reset it to match, and tell me here.
If it still doesn't work after that, generate another password that you can safely disclose (generate the user @localhost for safety), and tell me the full commandline incl. the password, as well as 'emerge info' output.
Comment 5 C J Pro 2005-01-20 17:40:04 UTC
Hashes match.

Got the networking working, and for some reason the password is required for external computers but is off on localhost...
Comment 6 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2005-01-20 17:46:54 UTC
Sounds like you have some other auth rules in place (that is matching localhost first). Have a look for a rule like %@localhost.

If you can't find it, attach the output of 'mysqldump -n -u root -p ... user' (with the passwords blanked out).
Comment 7 C J Pro 2005-01-20 18:04:56 UTC
# mysqldump -n -u root -p C_J_Pro
Enter password:
-- MySQL dump 9.11
-- Host: localhost    Database: C_J_Pro
-- -----------------------------------------------------
-- Server version       4.0.22
mysqldump: Got error: 1049: Unknown database 'C_J_Pro' when selecting database
Comment 8 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2005-01-20 18:10:15 UTC
dang, I cut off some of end of the command.

It's
'mysqldump -n -u root -p ... mysql user'

Replace ... with your root mysql password.
Comment 9 C J Pro 2005-01-20 18:20:26 UTC
Same error as my last reply.  Database user doesn't exist or database <password> doesn't exist.
Comment 10 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2005-01-20 18:22:55 UTC
I think you're running it wrong.
If my mysql root password is foo.
I would run:
mysqldump -n -u root -pfoo mysql user
Comment 11 C J Pro 2005-01-20 18:57:23 UTC
cjprogentoo Unreal3.2 # mysqldump -n -u root -p<password> mysql user
-- MySQL dump 9.11
--
-- Host: localhost    Database: mysql
-- ------------------------------------------------------
-- Server version       4.0.22

--
-- Table structure for table `user`
--

CREATE TABLE user (
  Host varchar(60) binary NOT NULL default '',
  User varchar(16) binary NOT NULL default '',
  Password varchar(16) binary NOT NULL default '',
  Select_priv enum('N','Y') NOT NULL default 'N',
  Insert_priv enum('N','Y') NOT NULL default 'N',
  Update_priv enum('N','Y') NOT NULL default 'N',
  Delete_priv enum('N','Y') NOT NULL default 'N',
  Create_priv enum('N','Y') NOT NULL default 'N',
  Drop_priv enum('N','Y') NOT NULL default 'N',
  Reload_priv enum('N','Y') NOT NULL default 'N',
  Shutdown_priv enum('N','Y') NOT NULL default 'N',
  Process_priv enum('N','Y') NOT NULL default 'N',
  File_priv enum('N','Y') NOT NULL default 'N',
  Grant_priv enum('N','Y') NOT NULL default 'N',
  References_priv enum('N','Y') NOT NULL default 'N',
  Index_priv enum('N','Y') NOT NULL default 'N',
  Alter_priv enum('N','Y') NOT NULL default 'N',
  Show_db_priv enum('N','Y') NOT NULL default 'N',
  Super_priv enum('N','Y') NOT NULL default 'N',
  Create_tmp_table_priv enum('N','Y') NOT NULL default 'N',
  Lock_tables_priv enum('N','Y') NOT NULL default 'N',
  Execute_priv enum('N','Y') NOT NULL default 'N',
  Repl_slave_priv enum('N','Y') NOT NULL default 'N',
  Repl_client_priv enum('N','Y') NOT NULL default 'N',
  ssl_type enum('','ANY','X509','SPECIFIED') NOT NULL default '',
  ssl_cipher blob NOT NULL,
  x509_issuer blob NOT NULL,
  x509_subject blob NOT NULL,
  max_questions int(11) unsigned NOT NULL default '0',
  max_updates int(11) unsigned NOT NULL default '0',
  max_connections int(11) unsigned NOT NULL default '0',
  PRIMARY KEY  (Host,User)
) TYPE=MyISAM COMMENT='Users and global privileges';

--
-- Dumping data for table `user`
--

INSERT INTO user VALUES ('localhost','root','<hash>','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
INSERT INTO user VALUES ('cjprogentoo','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
INSERT INTO user VALUES ('localhost','','','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','','','','',0,0,0);
INSERT INTO user VALUES ('cjprogentoo','','','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','','','','',0,0,0);
INSERT INTO user VALUES ('%','C_J_Pro','<hash>','N','N','N','N','N','N','N','N','N','N','N',
Comment 12 C J Pro 2005-01-20 18:58:23 UTC
Sorry, it didn't all copy.  You can see the output at http://pro5ive.info/mysql.txt
Comment 13 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2005-01-20 20:19:36 UTC
So lets clarify this, because it's not making sense here.

from a remote machine:
"mysql -u C_J_Pro -pPASSWORD -hSERVERIP"
fails

but from the local machine:
"mysql -u C_J_Pro -pPASSWORD"
works

Is this correct?
Comment 14 C J Pro 2005-01-21 11:43:37 UTC
Works for the first one, but fails on the second.
Comment 15 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2005-01-21 15:43:43 UTC
I suspect you did something not right with your /etc/hosts.
On the local machine, try:
"mysql -u C_J_Pro -pPASSWORD -hlocalhost"

then include the output of:
"getent hosts localhost"

it should be:
"127.0.0.1       localhost [maybe other host names here]"
it must be in that order.

Comment 16 C J Pro 2005-01-21 16:17:54 UTC
Output: 127.0.0.1 localhost

Should I downgrade to 2.0.18?  I had 2.0.18 running before I reformatted.
Comment 17 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2005-01-21 16:39:59 UTC
You didn't say if ""mysql -u C_J_Pro -pPASSWORD -hlocalhost" worked.

I'm really confused now as to why you can't get in locally, but your can get in remotely.
As a crazy test, try to add a user 'C_J_Pro@localhost', and see if that helps it.
Comment 18 C J Pro 2005-01-21 16:42:09 UTC
That first command didn't work and nor did this latest command.
Comment 19 C J Pro 2005-01-21 16:45:36 UTC
I just tried to compile anope and it returned -lmysqlclient missing.  Think this may be part of the problem?

BTW, I'm currently in #gentoo on irc.freenode.net if you want to contact me.
Comment 20 C J Pro 2005-01-21 17:06:38 UTC
cjprogentoo anope-1.7.7 # emerge info
Portage 2.0.51-r3 (default-linux/x86/2004.3, gcc-3.3.5, glibc-2.3.4.20040808-r1, 2.6.10-gentoo-r5 i686)
=================================================================
System uname: 2.6.10-gentoo-r5 i686 Intel(R) Pentium(R) 4 CPU 2.50GHz
Gentoo Base System version 1.4.16
Autoconf: sys-devel/autoconf-2.59-r5
Automake: sys-devel/automake-1.8.5-r1
Binutils: sys-devel/binutils-2.15.92.0.2-r1
Headers:  sys-kernel/linux-headers-2.4.21-r1
Libtools: sys-devel/libtool-1.4.3-r4,sys-devel/libtool-1.5.2-r7
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CFLAGS="-O2 -march=pentium4 -fomit-frame-pointer"
CHOST="i686-pc-linux-gnu"
COMPILER=""
CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config /usr/kde/3.3/env /usr/kde/3.3/share/config /usr/kde/3.3/shutdown /usr/kde/3/share/config /usr/lib/mozilla/defaults/pref /usr/share/config /var/qmail/alias /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-O2 -march=pentium4 -fomit-frame-pointer"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoaddcvs autoconfig ccache distlocks sandbox sfperms"
GENTOO_MIRRORS="http://gentoo.osuosl.org http://distro.ibiblio.org/pub/Linux/distributions/gentoo"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY=""
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="x86 X alsa apm arts avi berkdb bitmap-fonts cdr crypt cups dvd encode f77 fam font-server foomaticdb fortran gdbm gif gpm gtk2 imlib ipv6 java jpeg kde libg++ libwww mad mikmod motif mozilla mpeg mysql ncurses nls oggvorbis opengl oss pampdflib perl png python qt quicktime readline sdl spell ssl svga tcpd tiff truetype truetype-fonts type1-fonts xml2 xmms xv zlib"

Comment 21 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2005-01-21 19:18:09 UTC
closing as fixed now.