MySQL adds a service, sets a password, and changes the password. mysql changes the password.

Source: Internet
Author: User

MySQL adds a service, sets a password, and changes the password. mysql changes the password.

Fix: when you add a MySQL service, you can skip the version number. That is to say, all MySQL 57 can be directly written as MySQL! Please note that!

After MySQL is installed, some settings are required!

1. Add the MySQL service:

Enter command cmd

Enter the command cd D: \ software \ MySQL \ mysqllocation \ MySQLServer 5.7 \ bin (this directory is the MySQL installation directory)

Enter the command d to enter the MySQL bin directory.

 

Run the net start mysql57 command to check whether MySQL service exists (mysql57 is the version of my database)

If the MySQL service exists, you can directly start the service.

If the MySQL service does not exist, run the following command to add the MySQL service:

The MySQL service installation command automatically runs at startup:

Mysqld.exe-install MySQL57

The installation command is as follows:

Mysqld.exe-install-manual

2. Enable and delete service commands:

Enable the command: net start MySQL57

DELETE command: net stop MySQL57

3. set or change the password

After the MySQL service command is Enabled:

If you have not set a MySQL password before, the default MySQL password is blank!

Input: mysqladmin-uroot-p password will allow you to enter the password and press Enter!

Now let's enter the new password, so you can set a password you want, and then let you repeat the new password.

The password has been set!

If you have set a password and need to change it, enter:

The password is blank now!

4. Enter the MySQL database:

Run mysql-u-root-p.

If there is no password, press Enter. If there is a password, enter the password!

Exit Database: Enter the command quit;

 

Download Word documents

Thank you!


How to set a password for mysql

There are many methods:
1. After Entering mysql with root
Mysql> set password = password ('your password ');
Mysql> flush privileges;
2. Use the GRANT statement
Mysql> grant all on *. * to 'root' @ 'localhost' identified by 'your password' with grant option;
Mysql> flush privileges;

3. Go to the mysql database to modify the user table
Mysql> use mysql;
Mysql> update user set password = password ('your password') where user = 'root ';
Mysql> flush privileges;

How can I change the password set during MysqL installation through MySQL statements?

MySQL password change method summary

The first thing to note is: Generally, you need to have the root permission in MySQL to change the mysql password. In this way, you cannot change the password unless you ask the Administrator to help you modify the password.

Method 1

Use phpMyAdmin

(Graphical MySql database management tool), this is the simplest, directly use SQL statements to modify the user table of the mysql database, but do not forget to use the PASSWORD function, Insert the user using the Insert command, modify the user's use of the Update command and Delete the use of the Delete command. This section describes the user field of a data table.

Method 2

Use mysqladmin. Input

Mysqladmin-u root-p oldpassword newpasswd

After executing this command, you need to enter the original root password, so that the root password will be changed to newpasswd. Similarly, change the root in the command to your username, and you can change your password.

Of course, if your mysqladmin cannot connect to mysql

Or you cannot execute mysqladmin. This method is invalid, and mysqladmin cannot clear the password.

The following methods are used at the mysql prompt and must have the root permission of mysql:

Method 3

Mysql> insert into mysql. user (Host, User, Password) VALUES

('%', 'System', PASSWORD ('manager '));

Mysql> FLUSH PRIVILEGES

Specifically, this is to add a user with the username system and Password manager. Be sure to use the PASSWORD function, and then use FLUSH

PRIVILEGES for confirmation.

Method 4

Similar to method Sany, but the REPLACE statement is used.

Mysql> replace into mysql. user (Host, User, Password)

VALUES ('%', 'system', PASSWORD ('manager '));

Mysql> FLUSH PRIVILEGES

Method 5

Use the set password statement

Mysql> set password for system @ "%" = PASSWORD ('manager ');

You must also use the PASSWORD () function, but do not need to use flush privileges for confirmation.

Method 6

Use the GRANT... identified by statement to GRANT permissions.

Mysql> grant usage on *. * TO system @ "%" identified by 'manager ';

Here, the PASSWORD () function is unnecessary and you do not need to use flush privileges for confirmation.

Note: The PASSWORD () function is used to encrypt the PASSWORD. MySql automatically interprets it in the program .... Remaining full text>

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.