Another MySQL question

John Seth johnseth at phoenixwing.com
Tue Oct 7 23:44:26 EDT 2003


If you have a root password stored, and don't know what it is, you're
kind of SOL unless you remove the mysql database directory in
/var/lib/mysql. Then run, as root, run 'mysql_install_db'. Now, you can
run:
  mysqladmin -u root password 'newpassword'

If you know what the password is, run:
  mysqladmin -u root -p password 'newpassword'

This will prompt you for the current password, then it'll change the
current password to the one you selected. To erase the password,
providing you know what it is, type:

  mysqladmin -u root -p password ''

The password is encrypted with the password() function in MySQL.  If you
have the ability to edit the table directly, using phpMyAdmin (which I
recommend if you have a webserver and php available), another tool, or
directly. Run the following 3 SQL queries (this is a command line
example):

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+-----------------+
| Tables_in_mysql |
+-----------------+
| columns_priv    |
| db              |
| func            |
| host            |
| tables_priv     |
| user            |
+-----------------+
6 rows in set (0.00 sec)

mysql> UPDATE user SET Password = PASSWORD('newpassword') WHERE Host =
'localhost' AND User = 'root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.09 sec)

Done...

-- 
<? print(pack("c*", 74,117,115,116,32,/* Tony Evans                  */
 65,110,111,116,104,101,114,32,80,72, /* Linux/Web Implementation    */
 80,32,72,97,99,107,101,114,46,10));  /* http://www.phoenixwing.com/ */ ?>


> Can someone tell me where MySQL stores the Admin and
> user passwords for it's databases?
>
> Thanks
>
>
>
>
> --- One Untraceable <one_untraceable at yahoo.com> wrote:
>> Bob,
>>  That just gives me the mysqladmin help page..(Like
>> doing mysqladmin --help)
>>
>>
>> thanks
>>
>>
>> --- Robert Meyer <meyer_rm at yahoo.com> wrote:
>> > How about mysqladmin -uroot -ppassword
>> >
>> > Cheers!
>> >
>> > Bob
>> > --- One Untraceable <one_untraceable at yahoo.com>
>> > wrote:
>> > > I have just installed MySQL and I am attempting
>> to
>> > set
>> > > the root password and here is what I get. When I
>> > try
>> > > to run "mysqladmin" I keep getting this error:
>> > > [root at www bin]# mysqladmin -u root password
>> > > 'new-password'
>> > > mysqladmin: connect to server at 'localhost'
>> > failed
>> > > error: 'Access denied for user: 'root at localhost'
>> > > (Using password: NO)'
>> > > [root at www bin]#
>> > >
>> > >
>> > > Anyone have any ideas?
>> > >
>> > > Thanks
>> > >
>> > > __________________________________
>> > > Do you Yahoo!?
>> > > The New Yahoo! Shopping - with improved product
>> > search
>> > > http://shopping.yahoo.com
>> >
>> >
>> > __________________________________
>> > Do you Yahoo!?
>> > The New Yahoo! Shopping - with improved product
>> > search
>> > http://shopping.yahoo.com
>>
>>
>> __________________________________
>> Do you Yahoo!?
>> The New Yahoo! Shopping - with improved product
>> search
>> http://shopping.yahoo.com
>
>
> __________________________________
> Do you Yahoo!?
> The New Yahoo! Shopping - with improved product search
> http://shopping.yahoo.com
>
>




More information about the nflug mailing list