Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Setting MySQL root password

by NodeReaper (Curate)
on Dec 20, 2002 at 16:13 UTC ( [id://221466]=perlquestion: print w/replies, xml ) Need Help??

NodeReaper has asked for the wisdom of the Perl Monks concerning the following question:

Replies are listed 'Best First'.
Re: Setting MySQL root password
by mirod (Canon) on Dec 20, 2002 at 17:16 UTC

    This is vastly OT but hey, it happened to me just this month! It IS in the docs:

    A.4.2 How to Reset a Forgotten Password

    If you have forgotten the root user password for MySQL, you can restore it with the following procedure:

    1. Take down the mysqld server by sending a kill (not kill -9) to the mysqld server. The pid is stored in a .pid file, which is normally in the MySQL database directory:
      kill `cat /mysql-data-directory/hostname.pid`

      You must be either the Unix root user or the same user the server runs as to do this.
    2. Restart mysqld with the --skip-grant-tables option.
    3. Connect to the mysqld server with mysql -h hostname mysql and change the password with a GRANT command. See section 4.3.1 GRANT and REVOKE Syntax. You can also do this with mysqladmin -h hostname -u user password 'new password'
    4. Load the privilege tables with: mysqladmin -h hostname flush-privileges or with the SQL command FLUSH PRIVILEGES.

    Note that after you started mysqld with --skip-grant-tables, any usage of GRANT commands will give you an Unknown command error until you have executed FLUSH PRIVILEGES.

Re: Setting MySQL root password
by Nitrox (Chaplain) on Dec 20, 2002 at 16:18 UTC
    I'm unaware of a native Perl function that will reset the MySQL root password, but there are many nooks and crannies of the language that I'm still discovering. :-)

    -Nitrox

      You can do it using SQL to update the mysql database user table which is where the password lives. You can also use GRANT. You can also use mysqladmin as a system call to change passwords. Other than that it can't be done ;-) It is all in the extensive mysql docs for those inclined to RTM.

      Recovering from a lost root password is discussed below

      cheers

      tachyon

      s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://221466]
Approved by jerrygarciuh
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2024-04-23 20:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found