Web Hosting Talk







View Full Version : Change MySQL Root Password


WreckRman2
08-20-2001, 01:55 AM
Would someone be so kind to tell me how I can change my MySQL root password and what problems if any would I experience if I changed it?

Also can you shoot me the code to add a user to MySQL?

Thanks...

Eagle
08-20-2001, 05:44 AM
Login to the machine as root

kill the running mysqld "kill PID"
run mysqld with --skip-grant-tables "/usr/sbin/mysqld --skip-grant-tables &"
run mysql "mysql -u root mysql"
Then in mysql: "UPDATE user SET Password=PASSWORD('new_password')
WHERE user='root';"
next type "FLUSH PRIVILEGES"
"quit" mysql
kill mysqld and restart it with NO parameters
try "mysql -u root -p" then the old password. no luck. try again with the new one....WORKS! :-)
Enjoy.

Mike the newbie
08-20-2001, 07:15 AM
Originally posted by WreckRman2
Would someone be so kind to tell me how I can change my MySQL root password and what problems if any would I experience if I changed it?

mysqladmin -h hostname -u user password 'new password'

The only problem you should have is that you won't be able to get in if you forget the new password. However, you can look here (http://www.mysql.com/documentation/mysql/bychapter/manual_Problems.html#Resetting_permissions) if you need to get into mysql if you have forgotten your password.

Chicken
08-20-2001, 10:10 AM
Originally posted by WreckRman2
Also can you shoot me the code to add a user to MySQL?

Upload to folder (pass protect it unless you want the entire world to be creating db's on your server), and rename it index.php:

<<EDIT: You can now get it from the site listed below>>

WreckRman2
08-20-2001, 04:06 PM
Thanks guys...

jks
08-20-2001, 06:52 PM
Originally posted by Chicken


Upload to folder (pass protect it unless you want the entire world to be creating db's on your server), and rename it index.php:

I would appreciate credit where credit is due.

That script was created by me (and is available from our site at www.raqsupport.net).

sbrad
08-20-2001, 09:03 PM
I would appreciate credit where credit is due.
Oh, YOU'RE who wrote that. It's funny Chicken posted it here, because someone emailed it to me the other day, and I thought THEY had written it. Perhaps if you would have put something in the header indicating that you had written it. I think that would be the easiest thing to do.

Also, I modified it to be able to add separate username's and database names...rather than having the database name and username the same.
If anyone wants it, let me know. Or maybe you should let jks know. I don't know. What was I saying again?:eek:

<edit: I meant to say that the reason I was looking for it was to find a way to easily add a user with remote connection capability. This, IMHO, is the best part of this script!>

jks
08-20-2001, 09:10 PM
Originally posted by sbrad

Oh, YOU'RE who wrote that. It's funny Chicken posted it here, because someone emailed it to me the other day, and I thought THEY had written it. Perhaps if you would have put something in the header indicating that you had written it. I think that would be the easiest thing to do.


The script was available for free download from our website, where it says that the software is copyright by us (but you may freely download it and use it on your server).

If you take a closer look at the script, it's quite evident that for example Chicken didn't write it... the names of the variables are in Danish... (disclaimer: I don't know if Chicken happens to speak Danish - just an example)

Also, I modified it to be able to add separate username's and database names...rather than having the database name and username the same.
If anyone wants it, let me know. Or maybe you should let jks know. I don't know. What was I saying again?:eek:

The copyright on our page says that the copyright message should always accompany the script.

I'll go add that same statement to the script itself...

Chicken
08-20-2001, 09:11 PM
Originally posted by jks
I would appreciate credit where credit is due.

Credit given. If it seemed as though I was saying I wrote it, please understand that I did not write the script (for the others). i recently found it in my 'RaQ' folder on my HD and created a user/db. Had no idea who/where it came from, just that it worked.

sbrad
08-20-2001, 09:13 PM
The copyright on our page says that the copyright message should always accompany the script.
My point is, though, that there is NOTHING in the script indicating where it came from. So after being passed around a time or two, it's very easy for someone to not know where it came from. I'm not sure, but that's probably what happened with Chicken, also.

jks
08-20-2001, 09:16 PM
Originally posted by sbrad

My point is, though, that there is NOTHING in the script indicating where it came from. So after being passed around a time or two, it's very easy for someone to not know where it came from. I'm not sure, but that's probably what happened with Chicken, also.

That is being fixed now.

(I was not the one who put it on our homepage... I just wrote the script)

Chicken
08-20-2001, 09:18 PM
This is what happened. I'll replace my copy with a properly credited one (please include the URL of the site or the URL of the script), and next time I'll see that and be sure to copy the link instead of upload the script itself. My apologies... :(

jks
08-20-2001, 09:27 PM
Originally posted by Chicken
This is what happened. I'll replace my copy with a properly credited one (please include the URL of the site or the URL of the script), and next time I'll see that and be sure to copy the link instead of upload the script itself. My apologies... :(

The script is on:

http://www.raqsupport.net/utilities.html

I can see that us not having a copyright inside the script itself is a problem - so I have added that now. I got a little "carried away", as I read your earlier post as "here's something I made" ... I misunderstood it of course.

No harm done -- I'm only glad that people is using our software :-)

Chicken
08-20-2001, 09:37 PM
I'm glad you made it, worked like a charm when I recently needed a quick user and db. I feel *such* the dumb ass though... whooooo. Sorry about that, really....

WreckRman2
08-20-2001, 09:41 PM
I do not think Chicken was trying to avoid giving credit for a script you wrote. I merely asked for help and he shared a script he knew of. We all appreciate the work people do for others whether it is writing scripts or sharing them. Thanks Chicken for sharing it and thank you jks for writing it.

dutchie
08-24-2001, 09:52 AM
Hi,

Let me first tell you i know nothing about Mysql.

I installed the latest package from cobalt, and tried to change the password.

mysqladmin -h mydomain.com -u root cobalt-mysql mynewpassword

I generates a list with help topics.
When i just type

mysql -h mydomain.com

it connects me, no passwords nothing

Now i probably misunderstood the instructions because i'm a complete lamer :cartman:

Please someone give me another hint ?

jks
08-24-2001, 09:55 AM
Originally posted by dutchie

mysqladmin -h mydomain.com -u root cobalt-mysql mynewpassword


Try this instead:

mysqladmin -hmydomain.com -uroot -pcobalt-mysql mynewpassword

dutchie
08-24-2001, 11:06 AM
Thats slightly better, but still not good,

ERROR 1045: Access denied for user: 'root@www.mydomain.com' (Using password: YES)

Before it said Using password:NO, now its YES

Any Ideas ?

Chicken
08-24-2001, 01:04 PM
mysqladmin -uroot -pcobalt-mysql password *****

***** = your actual new password

dutchie
08-24-2001, 02:23 PM
Chicken this is the result:

mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user: 'root@localhost' (Using password: YES)'


What do i do wrong ?

mikeknoxv
08-24-2001, 04:46 PM
Are you completely sure your MySQL server is running?

MySQL provides some documentation on the subject. Click here (http://www.mysql.com/doc/C/a/Can_not_connect_to_server.html).

Chicken
08-25-2001, 01:30 AM
I'm wondering that myself, or if he already changed the password? i have no doubts the comand i listed works. Just had to do it the other day to change my root pass after accidentally posting it ot the forum heh! Whups....

dutchie
08-25-2001, 02:28 AM
I started with the instructions from Eagle, so it may very well not be running.

I tried the above link but it "cannot find server" on me.

How do i start Mysql or check its running ?

Chicken
08-25-2001, 04:48 AM
Check if MySQL is running, su to root and type:
ps aux | grep mysql

You should see list of processes running.

Also you can type:
/etc/rc.d/init.d/mysql start
(or /etc/rc.d/init.d/mysql stop to stop it obviously)

If you start it and it is already running, it will give you an error saying it can't be started because it is already running.

Mike the newbie
08-25-2001, 08:02 AM
After you confirm that mysql is running, if you are still having trouble with your password, look here to see how to reset the password:

http://www.mysql.com/documentation/mysql/bychapter/manual_Problems.html#Resetting_permissions

dutchie
08-25-2001, 01:50 PM
Well i ended up uninstalling it from the server, but it was running, i guess i entered a password somewhere, when i tought i did'nt.

So i have to install it again, as soon as my /admin starts working again :(

dutchie
08-26-2001, 04:44 AM
Ok i removed the mysql package, and started fresh, convinced it would work this time.

it didn't.

Now to make myself look really stupid, what is this page about, and do i need to follow this steps in order to make things work?

http://pkg.nl.cobalt.com/howto/casp_mysql_howto.shtml

Help me and i promise i'll buy a "MYSQL for Dummies" book tomorrow :)

dutchie
08-26-2001, 08:24 AM
i installed

http://pkg.nl.cobalt.com/i386/RaQ3-RaQ4-MySQL-3.23.37-1.pkg

And eventually it made my Raq die on me.
I want to thank Rackshack for their support in this sad event.
:)
I'll install a older version when its backup, does anyone else have experience with this package ?

p.s. i ordered the book

:)

mikeknoxv
08-26-2001, 08:29 AM
Originally posted by dutchie
i installed

http://pkg.nl.cobalt.com/i386/RaQ3-RaQ4-MySQL-3.23.37-1.pkg

And eventually it made my Raq die on me.
I want to thank Rackshack for their support in this sad event.
:)
I'll install a older version when its backup, does anyone else have experience with this package ?

p.s. i ordered the book

:)

I installed the latest stable of MySQL from source and it worked fine.

dektong
08-26-2001, 08:33 AM
Originally posted by Chicken
mysqladmin -uroot -pcobalt-mysql password *****

***** = your actual new password

I had this same problem before ... the above won't do good (in my experience, at least) if you already forgot your password. The above command is only good when you set your root password for the first time ... You can't reset your root password with that command, at least it did not work with me ...

The command recommended by mysql was that posted by eagle (see mysql docummentation (http://www.mysql.com/doc/R/e/Resetting_permissions.html)). Take a look at the note that follows it ... you might need to run safe_mysqld instead of mysqld ...

But even after I followed all the steps closely, I still could not get this to work .... After some good 3-4 hours or so, I decided to install a new version of mysql (upgrading to 3.23.40) and get all done in just 15 minutes ... :)

cheers,
:beer:

Chicken
08-26-2001, 01:47 PM
Originally posted by dutchie
i installed

http://pkg.nl.cobalt.com/i386/RaQ3-RaQ4-MySQL-3.23.37-1.pkg

And eventually it made my Raq die on me.
I want to thank Rackshack for their support in this sad event.
:)
I'll install a older version when its backup, does anyone else have experience with this package ?

p.s. i ordered the book

:)

Well, ok let's go back a bit. You did have mySQL installed and running before. Apparently you did set a password. Even if you removed the old version and reinstalled a newer one (the one you listed is fine, I have that running), that wouldn't fix your problem.

As dektong said, the command I listed would only change the root pass if you knew the current password. A password is set, you now have to switch to Plan B and reset the password (somewhat different than just changing it). I don't have that handy, but you aren't the first one to do this and they have info about the command needed at mysql.

I'm not sure what state everything is in, but you uninstalled mySQL instead of solving the problem.

Chicken
08-26-2001, 01:50 PM
Originally posted by dektong
I had this same problem before ... the above won't do good (in my experience, at least) if you already forgot your password. The above command is only good when you set your root password for the first time ... You can't reset your root password with that command, at least it did not work with me ...

This command will change the root pass, works any time, not just first time.

mysqladmin -uroot -p^^^^^ password *****

^^^^^ = current password
***** = new password

dutchie
08-26-2001, 02:25 PM
I'm not sure what state everything is in, but you uninstalled mySQL instead of solving the problem.

Here's what happend so far.

I got the raq, installed some patches, SSH, and MySQL.

I tried to set the MySQL password with the first solution mentioned in this topic. It didn't react like it should (i probably typed something wrong).
I then tried chickens spell, with no result. I rebooted the Raq, and the CP was really slow, so i uninstalled MySQL, and asked the RS Techs to reboot the Raq.

The next morning all was fine, played a bit with the DNS etc. And tried installing MySQL again, with exactly the same result.
No new pw and a slow CP after a reboot.
After the next reboot Apache died, according to the RS tech because of MySQL, i don't know maybe i messed up something else.

Its on a RS workbench now i assume cause its still down.

p.s. i didn't have any sites on it, since i got it "to learn" (and boy did i learn :) ).

I'm hasitating what version to install if it comes back up....

Chicken
08-26-2001, 05:01 PM
Install the one you listed, change the root pass, and you should be fine. I'm not sure what you did, but it isn't the norm (as you can probably tell). Careful! :D

dutchie
08-28-2001, 11:31 AM
Just to let you know:

I got a new raq from RS since mine was having big problems, i tried it again, and it worked like it should :)

Thank you