NEWS CATEGORIES:



NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
Home / News / Webmaster / Tips and Tricks

Tips and Tricks


How to Assign a Password to the Root Account on MySQL

Don`t forget the password

By Adrian Placinta, Web News Editor

28th of September 2007, 14:11 GMT

Adjust text size:



Enlarge picture
In yesterday's article I told you how to secure the anonymous accounts on MySQL. If you want to setup a password for root account, you have three possibilities.

The first method is identical with the one used to assign passwords for anonymous accounts. For that we will use the SET PASSWORD
method. The steps are: connect to the MySQL server as root and use the SET PASSWORD statements. To encrypt the passwords use PASSWORD function. These are the steps for Windows:
shell> mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('softpedia');
mysql> SET PASSWORD FOR 'root'@'%' = PASSWORD('softpedia');


For Unix, use these steps:
shell> mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('softpedia');
mysql> SET PASSWORD FOR 'root'@'host_name' = PASSWORD('softpedia');


In Unix environment, in the second statement replace 'host_name' with the name of the server host.

Another way to set up a password for the root account is to use mysqladmin. From there use the following commands:
shell> mysqladmin -u root password "softpedia"
shell> mysqladmin -u root -h host_name password "softpedia"


Use the same commands for Windows and Unix environment. Again, replace host_name with the name of the server host. You can use the double quotes only if your password has spaces or special character interpretable by the compiler.

The third method you may use to set up the passwords is to use UPDATE statement to alter users table directly from the database. Again, the UPDATE statement is the same on Windows and Unix environments.
shell> mysql -u root
mysql> UPDATE mysql.user SET Password = PASSWORD('softpedia')
-> WHERE User = 'root';
mysql> FLUSH PRIVILEGES;


After you assign the password for root, if you want to connect to the MySQL server you will have to supply the password.
shell> mysqladmin -u root -p shutdown
Enter password: (enter root password here)

TAGS:

MySQL | password | root | Windows | Unix
Read by 3,044 user(s) | Add comment | Link to this article TWEET THIS


Article rating:
Good (3.7/5) 10 vote(s)    

Subscribe to news | Print article | Send to friend

© Copyright 2001-2009 Softpedia
Contact:

 

 

SEARCH THE NEWS ARCHIVE :




Today's News
| Yesterday's News | News Archive


MORE RELATED ARTICLES:


MySQL Query Browser

MySQL Migration Toolkit

How to Secure Accounts in MySQL

Could Login Passwords Be Cracked?

How to Secure Your Password for MySQL

How to Install phpMyAdmin on Windows

How to Check MySQL Tables for Upgrade

Is Joomla! The Best CMS on the Planet?

Content Management System Selection

User opinions:

No user comments yet.
Be the first to express your opinion using the form below!

Share your opinion:

Your Name:
Your Email Address:
(will not be used for commercial purposes)
Solve this to prove you're not a bot: =
Your review/opinion:

 




Windows tabGames tabDrivers tabMac tabLinux tabScripts tabMobile tabHandheld tabGadgets tabNews tab

SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   ENTER NEWS SITE   |   ENGLISH BOARD   |   ROMANIAN FORUM