LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Mysql root password (http://www.linuxquestions.org/questions/linux-software-2/mysql-root-password-104677/)

spintrance7 10-16-2003 09:41 AM

Mysql root password
 
I just installed RedHat 9 console mode only. I got mysql service started and running but i dont know where to set the root password. Can you guys help?


thanks:D

snerfu 10-16-2003 10:24 AM

mysqladmin -u root password 'new-password'

noobist 10-19-2003 03:39 PM

what if you are stupid enough to forget your root password?

anyway to change it?

ive tried reinstalling in red hat 9, but it retains all the data (as you might expect).

i want to COMPLETELY reinstall it.. data passwords and all.

thanks in advance!

snerfu 10-20-2003 10:02 AM

http://www.mysql.com/documentation/m...ng_permissions

If you have set a root password, but forgot what it was, you can set a new password 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:

shell> kill `cat /mysql-data-directory/hostname.pid`

You must be either the Unix root user or the same user mysqld runs as to do this.
2. Restart mysqld with the --skip-grant-tables option.
3. Set a new password with the mysqladmin password command:

shell> mysqladmin -u root password 'mynewpassword'

4. Now you can either stop mysqld and restart it normally, or just load the privilege tables with:

shell> mysqladmin -h hostname flush-privileges

5. After this, you should be able to connect using the new password.

Alternatively, you can set the new password using the mysql client:

1. Take down and restart mysqld with the --skip-grant-tables option as described above.
2. Connect to the mysqld server with:

shell> mysql -u root mysql

3. Issue the following commands in the mysql client:

mysql> UPDATE user SET Password=PASSWORD('mynewpassword')
-> WHERE User='root';
mysql> FLUSH PRIVILEGES;

4. After this, you should be able to connect using the new password.
5. You can now stop mysqld and restart it normally.

noobist 10-20-2003 05:40 PM

there is no .pid file.. i killed mysql using gnomes process manager..

then followed the intructions but when i try to run the mysqladmin command it still denies me access (root@localhost using password: yes)

how do i start up mysql with the --skip-grant-tables option?
i have been saying "service mysqld start --skip-grant-tables"

but i dont think its working correctly!
.. sorry for being a pain

snerfu 10-21-2003 08:12 AM

What I would do after stopping mysql is to run:

mysqld --skip-grant-tables &

Then I would do:

mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('mynewpassword')
-> WHERE User='root';
mysql> FLUSH PRIVILEGES;


Exit out after that, and you should then be able to:

mysqlshow -u root -p

noobist 10-21-2003 03:15 PM

i got it!

thanks :)

mikeshn 11-29-2003 04:20 PM

I have the similar problem.

I had an account "mike" to mysql. But somehow I change the password. So now I have just one access to the system as root.
Trying to login to mysql as root with password and without password no success. Root password is: 123456.

What I'm doing wrong? I cannot connect to MYSQL as root.

[root@localhost init.d]# mysql -h localhost -u root -p
Enter password:
ERROR 1045: Access denied for user: 'root@localhost' (Using password: YES)
[root@localhost init.d]# mysql -h localhost -u root
ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)
[root@localhost init.d]#


All times are GMT -5. The time now is 12:39 PM.