MySQL Change root Password

How do I change MySQL root password under Linux, FreeBSD, OpenBSD and UNIX-like like operating system over the ssh session?

Setting up MySQL password is one of the essential tasks. By default, root user is MySQL admin account user. Please note that the Linux or UNIX root account for your operating system and MySQL root user accounts are different. They are separate, and nothing to do with each other. Sometime you may remove Mysql root account and setup admin user as super user for security purpose.
Tutorial details
Difficulty level Easy
Root privileges No
Requirements mysqladmin/mysql
Est. reading time N/A

Method #1: Use mysqladmin command to change root password

If you have never set a root password for MySQL server, the server does not require a password at all for connecting as root. To setup root password for first time, use mysqladmin command at shell prompt as follows:
$ mysqladmin -u root password NEWPASSWORD
However, if you want to change (or update) a root password, then you need to use the following command:

$ mysqladmin -u root -p'oldpassword' password newpass

For example, If the old password is abc, you can set the new password to 123456, enter:

$ mysqladmin -u root -p'abc' password '123456'

Note:123456 password is used for demonstration purpose only. You must select a strong password. It is an important protection to help you have safer MySQL database transactions.

Sample live session from my home server using mysqladmin

Fig.01: mysqladmin command in action

Fig.01: mysqladmin command in action

How do I verify that the new password is working or not?

Use the following mysql command:

mysql -u root -p'123456' db-name-here


mysql -u root -p'123456' -e 'show databases;'

A note about changing MySQL password for other users

To change a normal user password you need to type the following command. In this example, change the password for nixcraft mysql user:
$ mysqladmin -u nixcraft -p'old-password' password new-password

Method #2: Changing MySQL root user password using the mysql command

This is an another method. MySQL stores username and passwords in user table inside MySQL database. You can directly update or change the password using the following method for user called nixcraft:

Login to mysql server, type the following command at shell prompt:

$ mysql -u root -p

Use mysql database (type command at mysql> prompt):

mysql> use mysql;

Change password for user nixcraft, enter:

mysql> update user set password=PASSWORD("NEWPASSWORD") where User='nixcraft';

Finally, reload the privileges:

mysql> flush privileges;
mysql> quit

Sample live session from my home server

Fig.02: Changing mysql password for nixcraft user using sql commands.

Fig.02: Changing mysql password for nixcraft user using sql commands.

This method is also useful with PHP, Python, or Perl scripting APIs.

See also:

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 141 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
141 comments… add one
  • Tabitha Jun 5, 2007 @ 15:34

    I got an error trying to use your method to change the root password using mysqladmin. I did some checking and found that the following method worked.

    mysql> mysqladmin -u molly -p password NEWPASSWORD
    (replacing NEWPASSWORD with the desired password, you will be prompted to enter the current password)

    • Rajamohan Jul 1, 2010 @ 5:59

      Which Operating System you used….

    • LUCAS` Jul 31, 2010 @ 14:24

      This site is a mess !!!, now i can’t access to mysql *@*&#*&@)(***@)( you !!!

      • Henrique Jan 24, 2011 @ 19:11

        Lucas, you’re an idiot

      • idiots Mar 1, 2011 @ 10:37


      • John Aug 10, 2011 @ 3:37

        This was extremely helpful. its a simple query really… Just needed the correct syntax. Thanks administrator.

    • jim Aug 11, 2010 @ 18:31

      This is old, but someone might see it. Don’t forget to put the single quotes around your password.

    • Dhananjaya Jul 30, 2011 @ 14:18

      Really good post:

      i hacked my root by using that type + batch file
      Because i used special carectors for my password
      Thanks again ;)

  • Samuel Jun 6, 2007 @ 10:44

    I am using the latest MySQL, the codes above didn;t work for me, please if you have the correct code to use. I want to change the root password to null. Just like it came.


    • al Aug 9, 2011 @ 7:13

      mysql>SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘secret_password’);

      • Josh Sep 5, 2011 @ 7:48

        Al, thx. That worked fine for mysql. However when I try to access mysqladmin
        app now, I get a strange error.

        “The additional features for working with linked tables have been deactivated.”
        anyone have an idea for a fix?

        • Deirdre Oct 6, 2011 @ 21:28

          Hello, I need help creating a password. I don’t know where I am supposed to enter the SET PASSWORD command.

  • Edd Jun 18, 2007 @ 11:18

    computers can be sucha pain..!!


  • yesh Dec 20, 2007 @ 16:57

    Yessssss… same for me…
    It will not work.
    I use WAMPSERVER 2.0
    I get following error in Mysql:

    ERROR 1064 (42000): You have an error in you SQL syntax; check the manual that corresponds to your MySql server version for the right syntax to use near ‘$ mysql -u root -p
    mysql> use mysql
    mysql> update user set password=PASSWORD(“NE’ at line 1

    Very annoying

    • Josh Sep 5, 2011 @ 7:50

      I’m using wamp server 2.1. Click on your wamp icon. mouse hover on Mysql
      select console then type in Al’s suggestion. It worked fine for me.
      you may have to refresh your page or clear cookies before you see the change.
      I know I had too.

      • Josh Sep 5, 2011 @ 7:53

        oh yeah, if it asks you for a password and you haven’t set one yet, just press
        the enter key.

      • kingsley mbonu Jan 31, 2012 @ 14:46

        i want to set configure my mysql to set a new password i typed set password and the reply is this ERROR 1064 (42000): You have an error in you SQL syntax; check the manual that corresponds to your MySql server version for the right syntax to use near ‘$ mysql -u root -p
        mysql> use mysql
        mysql> update user set password=PASSWORD(“NE’ at line 1

        • Marabiloso Apr 22, 2014 @ 16:43

          This is a SQL statement.
          SQL statements only use single quotes, one at a time.
          use mysql
          update user root set password=PASSWORD(‘new’);

          this should work a lot better ;-)

    • Martijn Jul 18, 2016 @ 18:16

      Are you stupid ;)
      The mysql -u root -p doesn’t need to be entered in the mysql console. It’s the command to open the mysql console on linux systems.

  • K.Ramanathan Feb 6, 2008 @ 6:37

    The information on your website has helped me. Thanks.

    Best Wishes,

  • Alexander Elo Mar 17, 2008 @ 23:49

    Thank you very much, this information was usefull!

    – Alexander Elo

  • hardyboyz Apr 25, 2008 @ 17:35

    If I forgot my mysql password? how is it going?, because there is a step that need an old mysql password.

    • Inder Sep 21, 2011 @ 7:15

      ya I lost my Brain also :)

  • 🐧 nixCraft Apr 25, 2008 @ 19:02

    Go here to recover mysql password.

  • ryan May 14, 2008 @ 2:33

    Worked like a charm, thnx.

  • jessica Jul 17, 2008 @ 14:06

    thank you so much. i really needed this. ^^

  • Eutycus Aug 12, 2008 @ 6:40

    mysqladmin -u root -p password “newPassword” {enter}

    Enter password:”oldPassword”

  • Hendry Lee Sep 8, 2008 @ 1:30

    To update mysql password for root, the command that works for me is:

    mysqladmin -u root -poldpass password newpass

  • Daniel Sep 10, 2008 @ 14:41

    mysqladmin -u root -p password ”

    this will remove your password

    • dep Aug 9, 2011 @ 14:22

      Careful not to copy paste this. Use two single quotes instead of what you’d get if you copy/pasted this line.

      mysqladmin -u root -p password [singlequote][singlequote]

    • wild_teddy May 26, 2013 @ 13:59

      Thanks Daniel. After persistently receive Access denied, this finally worked :)

      mysqladmin -u root -p password

  • Bob Sep 23, 2008 @ 3:06

    I found this quite frustrating. Not an ideal post about how to change the root pwd. Hate it.

  • 🐧 nixCraft Nov 14, 2008 @ 5:37


    Whats wrong?

  • scott Nov 26, 2008 @ 19:56

    Have been coming here for years to cut and paste that syntax

    mysqladmin -u root password NEWPASSWORD

    works great, guys the “NEWPASSWORD” is where you put the new password

    it is lazier for me to come here to grab it than learn it myself, i

  • Spam Script Nov 26, 2008 @ 20:55

    There are people out there that should not be using computers, as yesh, bob & brendon.

  • Bhong Dec 2, 2008 @ 23:45

    Thanks for sharing this very useful info.

  • MIke nutt Dec 12, 2008 @ 13:46

    HI! It worked for me changing password this way, but when I trying to flush privileges it says : ERROR 1146 (42S02): Table ‘mysql.servers’ doesn’t exist.
    Whats wrong???

  • Vinod Rawat Jan 4, 2009 @ 13:00

    I was playing with WAMP tool. By default it had root password as empty. I wanted to provide a new password and not just leave it empty.
    By this I will be giving simple steps which I learnt, where in one can make necessary changes for both mysql server and mysql client. Hopefully this will work perfect with any standalone mysql server and mysql client application. I hope this may save someones precious time.

    WAMP Settings for MySQL
    By default WAMP does not set the mysql root password.
    So phpmyadmin connects to internal mysqlServer with default username : root and empty[NO] password

    If we want to have some form of secure database then root password should not be left empty.
    How to provide the password so that mysql client connects to the server with some password?

    The following tries to simplify the approach in WAMP Mysql setup.
    Mysql Server End Changes for new Password
    Change the mysql server password as follows :
    To setup root password for first time:
    mysqladmin -u root password “NEWPASSWORD”
    C:\wamp\bin\mysql\mysql5.1.30\bin> mysqladmin -u root password "root"

    If password already exist and you are aware of it and want to change it then
    1. Thru mysqladmin technique :
    mysqladmin -u root -p password “MYNEWPASSWORD”
    Enter password: OLDPASSWORD

    C:\wamp\bin\mysql\mysql5.1.30\bin>mysqladmin -u root -p password “vinod”
    Enter password: root

    2. Alternatively, [Optional Step]
    C:\wamp\bin\mysql\mysql5.1.30\bin>mysql -u root -p
    Enter password: root [OLD EXISTING ROOT PASSWORD]
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 8
    Server version: 5.1.30-community-log MySQL Community Server (GPL)

    Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

    mysql> use mysql
    Database changed

    mysql> update user set password=PASSWORD("vinod") where User='root';
    Query OK, 1 row affected (0.00 sec)
    Rows matched: 1 Changed: 1 Warnings: 0

    mysql> exit

    This changes the root password.

    Verify :

    C:\wamp\bin\mysql\mysql5.1.30\bin>mysql -u root -p
    Enter password: vinod
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 5
    Server version: 5.1.30-community-log MySQL Community Server (GPL)

    Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.



    Mysql Client End Changes for new Password
    Change the mysql client password as follows :
    Here phpmyadmin is a mysql client application which is connecting to mysql server.
    Let us see what it requires to make changes to successfully connect with new password

    1. Edit under C:\wamp\apps\phpmyadmin3.1.1\

    $cfg['Servers'][$i]['password'] = '';
    $cfg['Servers'][$i]['password'] = 'vinod';

    Thats it restart mysql service and http://localhost/phpmyadmin/ will let u login

    • 🐧 nixCraft Jan 4, 2009 @ 13:04

      Thanks for sharing Windows specific information.

    • Rick Sep 17, 2010 @ 3:05

      Awesome! Thanks for saving me a ton of time!

    • Little Box Oct 30, 2010 @ 12:39

      Thank you for this info. I tried to change the password in the my,ini file (i’m a beginner), but it didn’t work. i searched on google, and I found this :D Very useful.
      I’ll make a post on my blog about this :D

      PS: Don’t be affraid Vivek, I won’t copy your post ;)

      Have a great day!

    • Dare Nov 29, 2010 @ 18:56


      thank you so much. This detailed tutorial helped me change the password in 5 min.


      • Patrick Mar 17, 2011 @ 14:56

        Thanks Vinod!!!!!!!!!

        Your solution is the only one that worked.

  • Jnanesh Jan 6, 2009 @ 11:03

    Thanks Vivek.
    It worked for me.

  • josh from america Jan 13, 2009 @ 23:06

    Windows is the festering bit of useless tripe that you hope does not appear on your porch, but if it does you kick it off and wash your shoe.

    Keep it in joke computing world and off of serious informative boards please.

  • Unbiased Jan 21, 2009 @ 22:06

    Operating Systems are SRS BSNS.

    But seriously, get over yourself, “Josh from America”, and stop posting such self-righteous fodder. No one cares what you think. This is supposed to be an area for assistance.

  • morg Jan 29, 2009 @ 9:40

    when setting the root password for the first time, start a DOS terminal and run
    C:\wamp\bin\mysql\mysql5.1.30\bin> mysqladmin -u root password “root”
    like in vinod’s post. here the ‘mysqladmin’ is not a command, but an exe file!

    yesh: do NOT use mysql console for this, because it does not recognise the command, and you keep getting new prompts and error messages.
    first I made the same mistake. Thanks Vinod!

  • HappySpaceInvader Feb 10, 2009 @ 10:47

    The problem with your examples, is that it is not clear which parts are literal and which parts are to be substituted.

    I have been trying to get your example to work to change the existing root password, but in your example of: “mysqladmin -u root -p oldpassword newpass” are both of the last two arguments meant to be substituted or just the first one. And then, at the prompt, do I enter the old password, or the new one I want to create? It’s terribly unclear.

  • HappySpaceInvader Feb 10, 2009 @ 10:58

    Here is a foolproof way of changing your root password without mucking around with prompts and error messages:

    mysqladmin –user=root –password=’my_old_password’ password ‘my_new_password’

  • charu Feb 16, 2009 @ 11:23

    My user name and password are not working while I am opening my ID. It says this is not a valid ID but i gave correct ID and password. I want my previous ID and password because this is my favourite ID

  • kathirvel Mar 18, 2009 @ 5:12

    nice one helped me in time

  • Kenneth Gustine Mar 27, 2009 @ 6:45

    To clear the root password I got a “too few arguments” with

    mysqladmin -r root password

    instead, mysqladmin -r root password “” ( MUST be double quotes )

    I then entered the root password and this cleared it.

  • ThunderGod Mar 30, 2009 @ 22:12

    tnx it worked but i changed it a little i used this
    mysqladmin -u root -poldpass password Newpass

  • Andy Towler Apr 9, 2009 @ 8:19

    Thanks go to Vinod Rawat – a useful and easy to follow comment, resolved my issue in 2 minutes flat.

  • gorg Apr 16, 2009 @ 13:30

    Thank you very much for this information. I have been searching for hours on a correct technique for something as simple as changing the passwords of mysql users and most pages are just plain wrong with continuous comments complaining about failure. I hated being apart of that failure. I found your site and the solution was simple and correct. This has made me much more productive with my sites by not having to continuously change the username and password in the site code. Thank You!

  • Dan May 13, 2009 @ 19:28

    Hey thanks!, quite frankly, the windows tip got it done in a snap! o.O… who says open source is free… it’s only free if your time is worthless :o!

  • rahul May 29, 2009 @ 0:22

    I login via SSH to my server, and then, into of my vps, write “mysql” and I can access (not need put root psswd mysql).

    Can you help me?.

  • Ankur Kaushik Jun 12, 2009 @ 10:15


  • Sureshkumar Jun 22, 2009 @ 9:12

    Superb !!!!!!!!!!!!!!!

  • john black Jun 29, 2009 @ 10:36

    Thank you for your help.
    mysqladmin -u root -p’oldpassword’ password newpass
    Before successfully changing my password using your script I got single quotes around my new password (and a warning.) So I did like this:-
    mysqladmin -u root -p”‘oldpassword'” password oldpassword
    It worked! What a performance!
    Linux seems easier than Windows XP.

  • khan Jul 4, 2009 @ 21:56

    The above command did not work for me, perhaps i am using latest version of mysql but the following did

    C:\xampp\mysql\bin>mysqladmin -u root -p”1234″ password “”

    1234 is old password. New password is blank. I tried different variation but it never worked. It did not ask for password confirmation this time and i was able to login using a blank password. Note that i used double quotes to wrap both old and new password. Hope it helped. I am using MySQL 5.1.29 which i believe is latest.

  • john black Jul 5, 2009 @ 11:58

    I suggest that it is different for different versions and between Windows and Linux.
    I suggest that you, Khan, have changed your password to “” which will be treated as no password.
    What you did that worked was:
    C:\xampp\mysql\bin>mysqladmin -u root -p”1234″ password “”
    I suggest that it might have worked without the double quotes.
    Now that I have got it working I really don’t want to try it and mess up my system.

    Version 5 is the first version of Mysql that I have managed to make work.
    I have installed many earlier versions and have always come unstuck about the password.
    It really is a nightmare.
    I am not a giant corporation with hackers trying to steal my credit card info using code injection.
    I am just a home user who wants to learn Mysql.

  • sandeep Jul 11, 2009 @ 15:49

    I get an error for the flush privileges command – error 1146 (42s02): Table ‘mysql.servers’ doesn’t exist

    Is reloading the privileges very important – or will this not affect at all?

  • yudymardianto Jul 28, 2009 @ 4:09

    very Useful this article.

  • jason Aug 19, 2009 @ 18:20

    mysqladmin -u root -p”oldpass” password”newpass”

    replace oldpass with your old password. replace newpass with your new password. leave the quotation marks “”.

    thanks again for this post , esp thundergod.

  • Ste ve Aug 21, 2009 @ 16:20

    This just doesn’t work. I have version 5.0.84 on a windows server.
    It doesn’t work without quotes, with quotes, double quotes or brackets…

    I’ve never set a pasword, so I just try
    $ mysqladmin -u root password NEWPASSWORD

    And it doesn’t work. Please help.

  • edi Sep 5, 2009 @ 10:10

    hello i am just use wamp but when i open phpmyadmin , i found this alert ,
    “Your PHP MySQL library version 5.0.51a differs from your MySQL server version 5.1.32. This may cause unpredictable behavior.”

    can anybody help me to fix this ?

  • john black Sep 6, 2009 @ 0:17

    Hello edi,
    I see that you are having problems too.
    Welcome to the club.
    “Your PHP MySQL library version 5.0.51a differs from your MySQL server version 5.1.32. This may cause unpredictable behavior.”
    I have never used wamp precisely because of this sort of problem.
    If all goes well wamp is a very easy way to install Apache, PHP and MySql.
    But when something goes wrong as in your case it is very difficult to fix.
    I think that your error message means exactly that.
    Had you installed the three packages separately it would have been less trouble.
    Before you uninstall wamp and install Apache, PHP and MySql separately,
    I would try uninstalling MySql, uninstalling PHP and then installing PHP and then MySql.
    You do need to download PHP and MySql separately.
    But having said that you might be better off starting again
    with a fresh install of Apache, PHP and MySql.
    Each is dependent on the previous installation thus Apache can run on its own.
    PHP depends on Apache. MySql depends on PHP.
    You must work up to the full installation, uninstalling a part if it does not work.
    Just to add a layer of complication, for some reason PHP no longer supports MySql
    without a few extras. Some dispute between Sun Microsystems who support MySql
    and PHP which is open source.
    Your C:\PHP\ext folder needs to include a few extra dll files
    which need to be enabled in your php.ini.
    I could say more but it is well documented on the internet.
    Yes it is a challenge. Good luck. It will work eventually.

  • Srikanth Sep 15, 2009 @ 6:57

    Thanks a Lot :)

  • nicoliniyo Nov 3, 2009 @ 14:09

    This is really usefull!

  • pictuality Feb 15, 2010 @ 20:42

    Hi all,

    Am using WAMP – with MySql 5.1.36.

    Currently have no password set for root. Open to all. None of the above solutions work for me. Does anyone know how to set root password – WAMP Mysql 3.1.36 ? Please don’t suggest any of the above!


  • pictuality Feb 15, 2010 @ 23:36

    Hi Vinod,

    Hope you can help.

    You say that to set a password (in WAMP when one hasn’t been set) to:

    To setup root password for first time:
    mysqladmin -u root password “NEWPASSWORD”
    C:\wamp\bin\mysql\mysql5.1.30\bin> mysqladmin -u root password “root”

    I don’t understand, – which one is it?

    Do I use your first line and enter my chosen password where you have “NEWPASWORD”
    or do I use your second line and enter “root” ?

    If I use your second line and enter “root”, do I then get to set the password I want?

    Why do you give two conflicting lines? Sorry, all new to me.

    I also found out from another site that you have to navigate from command prompt to the bin directory that contains the mysqladmin.exe file before trying to run the command. That isn’t very clear here.

  • sphiwe Feb 18, 2010 @ 9:27

    hi all.
    iam usin wamp 2.0 with mysql 5.1.36.

    i hv 2 tables, subjects and pages, pages relates to subjects vai subject_id. iam buildin a site, wen i try 2 retrieve pages 4rm my data base dat hv a relationship with a subject(…$query = select * FROM pages WHERE subject_id = {$subject_id}…) it gvs me an error dt reads: you hav an error in ur sql syntax; check manual that corresponds to your mysql server version. somebody please help me, thanx.

  • Greg Mar 12, 2010 @ 23:06

    When I tried this, it didn’t seem to change the mysql password..

    not to fear though I did find the fix.

    Note: If your mysql user account doesn’t have root access it can’t read the .sql script you just created. Easy way around it is to make the file in /tmp or have your mysqld_safe running with root privileges. other wise works like a charm.

  • boriss Mar 18, 2010 @ 19:35

    Thank you very much, this information was usefull!

  • gary Apr 8, 2010 @ 20:18

    Apparently, I fat-fingered the password for my root. I have attempted to use the posts here, and quite likely overlooked the solution. However, is there a simple command to clear the password if it is not remembered? I am guessing that reinstalling mySQL would not work because this is stored in the registry, so my next question is where I find that. I have full admin rights and this is my box, but I obviously went astray and need the program for a college class.

    All help is greatly appreciated.


  • gary Apr 8, 2010 @ 20:22

    As a follow up, I am using a Dell 1640 XPS with 64-bit operating system and mySQL server 5.1.


  • Jack Jul 13, 2010 @ 7:35

    I am running a local MAMP server on my MacBook Pro (Mac OS X – 10.6.4) and running MySQL 5.1.48 (x86_64) and found out that the following command would cause root to longer have access to the “mysql” database after logging out and logging back in:
    mysql> update user set password=PASSWORD(“NEWPASSWORD”) where User=’root’;

    The fix was to replace the double quotes with single quotes around the new password in the sql statement. So the command looked like this:
    mysql> UPDATE mysql.user SET Password=PASSWORD(‘newpassword’) WHERE User=’root’;
    Also don’t forget to refresh the grant tables with this command:

    But what I recommend is using the SET PASSWORD syntax b/c the update will let you pass any value which could cause trouble and headaches, plus its just a longer command.
    mysql>set password for ‘root’@’%’ = password(‘newpassword’);

  • Pule Jul 21, 2010 @ 3:52

    Thanks you very much. I spent the whole day searching for this. Yay!!!

  • Tash Pemhiwa Jul 28, 2010 @ 13:31

    Brilliant! Had checked the mysqladmin command but was in doubt. Thanks for clearing up my doubts. Worked perfectly!

  • Camilo Sep 20, 2010 @ 0:03
    • ric Sep 26, 2010 @ 8:40

      Good Day! i have system in server and it runs in linux(fedora 6),a program(system)php and mysql,the system is in www folder in linux,now i want it to run in windows xp,i installed wamp in my windows xp,i copy and paste the system(which is the system in linux) in www folder under folder wamp(c>wamp>www),i start all services(php,mysql,apache),i open phpMyAdmin and import the sql files(which is i exported from linux phpMyAdmin, compose of tables etc…)..and then i try to run the system using hxxp://localhost/system/index.php, it runs like in linux,now asking the username and password like in linux as administrator,when i entered username and password like in linux,or even wrong or none,it has an appears ”
      Not Found

      The requested URL /system/Notice: Undefined variable: PHP_SELF in C:\wamp\www\system\index.php on line 55 was not found on this server.”

      then if i import sql file in phpmyadmin,this information appear “Your configuration file contains settings (root with no password) that correspond to the default MySQL privileged account. Your MySQL server is running with this default, is open to intrusion, and you really should fix this security hole by setting a password for user ‘.root’.

      WHAT HAPPENED?WHAT SHOULD I DO FOR IT?THANKS GUYS…im looking forward for ur help…thank you and GOD BLESS!

  • Dr. Mussadiq L Nov 6, 2010 @ 6:09

    thank you believe me its fantastic. God bless you. Allah will give you the reward for spreading useful knowledge. love you . thankkkksss it solved my problem keep posting data like this

  • Said Nov 14, 2010 @ 1:36

    Hi, would like to say thank you – I followed your advice and it worked for Wamp 5 (thought I had lost several websites I’m developing before I came across your post). Brilliant and God bless you. Said

  • James Aaron Devlin Nov 18, 2010 @ 9:26

    Thank you very much Vivek.

  • Ali Abid Nov 30, 2010 @ 9:43

    Excellent article. Simple but with most useful information in excellent manners.

  • kamal Dec 26, 2010 @ 1:23

    Its worked although searching many websites.I work on SUSE 11.3.
    Thanks a lot

  • ferrero Jan 13, 2011 @ 22:11

    Thanks, its works fine for me.

  • thenoid Jan 29, 2011 @ 11:17

    Very thank you! =)

    • Deepak Feb 18, 2011 @ 3:38

      Can any please solve this problem?

      [deepak@localhost]$ mysql -u root -p mysql123
      Enter password:
      ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)

  • Oscar D'Antona Feb 24, 2011 @ 23:15

    Thaks a Lot !!!!!!! that was was easy
    you were very clear
    thak you

  • Gabriel LopezSeco Mar 16, 2011 @ 19:42

    I have consistently found the information on this website very helpful. Especially during my beginning into Linux.

    I’ve seen some harsh comments here, that I think may be completely unfair.

  • DynoDan Mar 30, 2011 @ 19:16

    I realize this is an old post, but someone like me may stumble on to this issue. I am currently using mysql version 5.0.91 and this is what worked for me. When using the command line shown below, one thing to remember is that there is no space between the -P and the password. There is however spaces between -u and root, and between password and “newpass”.
    mysqladmin -u root -p”oldpass” password ”newpass”

    So, if the old password was abcde, and the new password is fghij, the command line would look like this:
    mysqladmin -u root -pabcde password fghij

    if you enter this like this, with the space between -p and abcde, mysql will prompt you for a password, and further will not recognize the abcde as a valid command.
    mysqladmin -u root -p abcde password fghij

    I am not sure why this is, but I can say this worked for me.

  • Chris Apr 6, 2011 @ 7:07

    How to change the domain name in the database table?

    Having to use a another mysql wordpress database for another domain/site, I need to change the domain name inside the database but have no idea which table/s containing the domain name and how to change it.

    Any assistance and guidance would be much appreciated.

    Thanks in advance

  • Jared Apr 12, 2011 @ 20:58

    Thanks for this info. Worked great!

  • Rupesh Apr 25, 2011 @ 12:12

    Thanks it helped.

  • NargoT May 5, 2011 @ 15:09

    Thank you !!!!!!!

    • bruce Jun 10, 2011 @ 11:27

      how do I change my entery password to my computer.

  • Edwin Jul 8, 2011 @ 11:56

    i got problem when i login i enter the user name but password i didn’t know

  • Askar Ali Sep 12, 2011 @ 9:59

    Thanks for sharing.

  • rahardja Sep 14, 2011 @ 3:11

    Tengs, that’s really help me my local web can work properly . :)

  • tamashebi Sep 22, 2011 @ 9:01

    I cant change my password on fedora.
    I have this warning. error: ‘Access denied for user ‘root’@’localhost’ (using password: NO)’
    please help

  • Inder Sep 23, 2011 @ 7:13


    Search for a file “” you will find it in “wamp\apps\phpmyadmin3.2.0.1” like folder

    just change the password in this file on line looking like “$cfg[‘Servers’][$i][‘password’] = ‘password’; ”

    then Save !


  • akshay Nov 3, 2011 @ 10:41

    Thank you..! Worked fine…!

  • anne Dec 11, 2011 @ 17:48

    I am getting these type of errors
    MySQL said:

    #1045 – Access denied for user ‘root’@’localhost’ (using password: NO)

    Connection for controluser as defined in your configuration failed.

    phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.

    Actually, earlier http://localhost/phpmyadmin was running fine.. but since i have installed MySQL server, and during configuring the instance i have given a simple password it had stop work and displaying the errors written above.
    Also the command presented in this blog are not working at my system’s command prompt.

    I m thinking to remove the root password, but i guess there may other solution as well to bypass/remove these type of errors.

  • Name Dec 12, 2011 @ 17:33

    #1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘mysql> update user set password= PASSWORD(“[password]”) where User='[username]” at line 1

  • April Hannaford Jan 18, 2012 @ 4:08

    I just wanted to say thanks for this article. It help save me so much time… Thanks…

  • José Luis Olmedo M. Mar 2, 2012 @ 20:44

    Thank you for your help.
    You article is excelent.

  • tibi Jun 4, 2012 @ 11:39


    it works fine but i would not advice to do it like this:
    mysqladmin -u root -p’abc’ password ‘123456’
    because the entered password will be on your console. and will go into your history. this is not secure. when doing it like this:
    mysqladmin -u root -p password
    the mysqladmin will ask for your old and new password. which will not go into your console and not into your history.

    besides this it helped me alot thanks!!

    • Warntjo Oct 4, 2012 @ 11:42

      Thanks Tibi, that worked : ).

  • steven Jun 25, 2012 @ 7:01

    thank you.

  • bdeveloper Jul 2, 2012 @ 9:27


  • Andrei Jul 4, 2012 @ 10:00

    For Chris, Download and install WAMP, use PhpMyadmin to RENAME your database(slect your database , chose OPERATION) , I hope you are able to do this! If not, do some Google, for PhpMyadmin .

  • SUDHAKAR K Aug 9, 2012 @ 12:52

    Thanks for this tutorial..
    really its helpful doc


  • moosa Aug 15, 2012 @ 10:09

    thanks alott..

  • Notandi Nov 12, 2012 @ 13:21

    I had tried everything. Finally bit the bullet, reinstalled Ubuntu worked around the problems that came up in this walkthrough and got it to work in 5 min.

  • sebro Nov 26, 2012 @ 16:15

    Any help appreciated
    Broses-MacBook-Pro:~ Watlala$ /usr/local/mysql/bin/mysqld_safe –skip-grant-tables
    121126 18:10:56 mysqld_safe Logging to ‘/usr/local/mysql/data/Broses-MacBook-Pro.local.err’.
    touch: /usr/local/mysql/data/Broses-MacBook-Pro.local.err: Permission denied
    cat: /usr/local/mysql/data/ Permission denied
    rm: /usr/local/mysql/data/ Permission denied
    121126 18:10:56 mysqld_safe Fatal error: Can’t remove the pid file:
    Please remove it manually and start /usr/local/mysql/bin/mysqld_safe again;
    mysqld daemon not started
    /usr/local/mysql/bin/mysqld_safe: line 107: /usr/local/mysql/data/Broses-MacBook-Pro.local.err: Permission denied

  • Sauef Sufal Dec 12, 2012 @ 6:54

    Thanks very much, i can summarize like that
    simply type three commands below noted:

    command 1: use mysql;
    (prompt will display database changed
    command 2: update user set password =PASSWORD(“PUT YOUR PASSWORD HERE”); where user=’root’;
    Command 3: fulsh privileges;

  • Kaniya Feb 22, 2013 @ 16:41

    better way before upgrade older version of phpmyadmin take the backup. and after replace the config.ini.php from old version.

    it is working

    above all the other fuckers are liars… i hate

  • Betta Mar 6, 2013 @ 11:57

    Great job helped me …10x..

  • Joye Mar 22, 2013 @ 8:40

    Thanks a lot !!
    You just saved my ass :) It was really a great help!!

  • DexCript Apr 11, 2013 @ 19:51

    Very Helpfull this article, it will work for some users and not for others ( diferente mysql version, or different mysql client etc… ), before posting crap about, looking in your environment….. so dummies!!!

  • Sumit singh Apr 25, 2013 @ 5:58

    mysql> update mysql.user set password=password(‘newpassword’) where user=’root’ and host=’localhsot:3307′;
    Query OK, 0 rows affected (0.00 sec)
    Rows matched: 0 Changed: 0 Warnings: 0
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    mysql> quit;

  • nickchacha Jun 13, 2013 @ 12:23

    Thanks to you now am able to login into mysql using PhpMyadmin.
    Excellent article.
    Again Thank you.

  • massss Jul 28, 2013 @ 7:39

    i have an error while
    mysql> where user=”root”;
    error is ::

    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
    corresponds to your MySQL server version for the right syntax to use near ‘where
    user=”root”‘ at line 1

    what shud i do???

  • Strateji oyunu Aug 20, 2013 @ 2:56

    For Chris, Download and install WAMP, use PhpMyadmin to RENAME your database(slect your database , chose OPERATION) , I hope you are able to do this! If not, do some Google, for PhpMyadmin .

  • Jose Tapia Sep 18, 2013 @ 23:27

    I really appreciate your help, thanks for the info bro

  • David Gillies Oct 10, 2013 @ 19:07

    On a modern Linux system this is the quickest way to force-reset the password (e.g. if you have forgotten it or taken over a legacy system), assuming it is running as a system service:

    service stop mysql
    mysqld_safe --skip-grant-tables &
    mysql> UPDATE mysql.user SET Password=PASSWORD('new password') WHERE User='root';
    mysql> quit
    mysqladmin shutdown
    service mysql start
  • jas singh Nov 14, 2013 @ 4:25

    What if I don’t know my current password ? Im getting the following message > -bash: $: command not found <

    I tried to remove the password in phpmyadmin (MAMP) then everything stopped working and I cannot connect to mysql server.

  • Roxysteve Dec 6, 2013 @ 22:06

    So much vitriol, so many spelling errors. In the attached code.

    Many years ago an old Cobol programmer from Manchester told me that he got into programming because he couldn’t spell. With computers, he only had to learn about thirty words. The rest of the time, he could mis-spell to his heart’s content so long as he did it consistently.

    Biggest, bestest hint I ever got from a teacher. I’ll try and follow suit by mentioning that MySQL likes single quotes much more than it likes double quotes. Most of the “syntax error” bewilderment here can be traced to people trying out the wrong sort (or worse, one of each).

    You should also try:
    >mysql -u root -p
    >[password] – your password, not literally [password]
    >use mysql ;
    >show tables;
    >describe user;
    >select host, user from user where user = ‘root’;

    There’s a lot of useful stuff in what you’ll see that should get you thinking in the right way when it comes to setting up your utility users.


  • Amani Musomba Jan 28, 2014 @ 5:39

    The below simple procedure works..

    use mysql;
    UPDATE user SET password=PASSWORD(‘NEWPASSWORD’) WHERE user=”;
    flush privileges;

  • Amani Musomba Jan 28, 2014 @ 5:40

    The below simple procedure works..

    use mysql;
    flush privileges;

    • se thu myo May 19, 2015 @ 9:25
      use mysql',  
      UPDATE user SET
      flush privileges
  • Chris Apr 23, 2014 @ 3:39

    Great tutorial. This saved me a lot of hassle. Thank you.

  • Wycliffe Apr 26, 2014 @ 11:08

    Easy and precise. Didn’t take me more than two minutes to create edit and test

  • umair hassan Aug 21, 2014 @ 0:30

    I want some help regarding goautodial. I have change the pasword of mysqladmin and i also want to change the password of phpmyadmin which is by default user name is cron and pasword is 1234 so my que is how to change the password of phpmyadmin and where i can saw these all passwords if i forget in some case.


  • Steven Apr 19, 2015 @ 17:41

    Just a suggestion for method 1–instead of putting the password into the actual command, just use this: “mysqladmin -u root -p password” (no quotes but exactly how I wrote it). It will first prompt for the current password and won’t display it in the window, then it will prompt for the new password twice, again not actually displaying the text.

  • Puspendra Jul 14, 2016 @ 5:02

    does it effect on database;

  • Luis Dec 10, 2016 @ 1:52

    I’m use Method #1 in a one Red Hat Enterprise Linux 7.3 into a Amazon EC2 instance, and work just fine !

  • Raschad Jan 21, 2017 @ 21:00

    I have problem that I forgot my temp password how can i fix it? please help me :/

  • Shivoy Feb 19, 2017 @ 3:55

    My mysql application is telling me to reset the password using “alter user” method …..what does that even mean….how can i do that?? please help if u know how to figure that out…thanks

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum