Set the root password after installing MySQL under Linux

Source: Internet
Author: User

Method One: The simplest method, but also after installing MySQL, the system prompt method. Use Mysqladmin to complete.
shell> mysqladmin-u Root Password"newpwd"Shell> mysqladmin-u root-h host_name password"newpwd"

The double quotes behind the password are not necessary, but if the password contains spaces or some special symbols, you need to use quotation marks. Method Two: Use the MySQL inside the Set password command to complete, note must use the password () function to encrypt the settings of this newpwd, otherwise direct ='newpwd'will not take effect. However, if you use the Mysqladmin password to set a password or grant to set it, you do not need to use the password () function, because they have already called the function automatically. shell> MySQL-u Root
MySQL> SET PASSWORD for'Root'@'localhost'= PASSWORD ('newpwd'); MySQL> SET PASSWORD for'Root'@'host_name'= PASSWORD ('newpwd');
Method Three: Set the password shell directly via the Update user table> mysql-u rootmysql> UPDATE mysql.user SET Password = Password ('newpwd'), WHERE User ='Root'; MySQL>FLUSH privileges; If you forget the root password of MySQL, you can take the following steps to reset1. Kill all MySQL processes.2。 Using--skip-grant-tables Parameters Start Mysqlshell> Mysqld_safe--skip-grant-tables &3. Set a new password, the same two ways you can choose the method of a shell> mysqladmin-u root flush-privileges password"newpwd"use method One error, try to use method two. Method two MySQL> UPDATE mysql.user SET password=password ('newpwd')--WHERE user='Root'; MySQL>FLUSH privileges;4. Stop MySQL server and start with normal mode5。 OK, you can use the newly-set password.

Set the root password after installing MySQL under Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.