MySQL initializes the root password and allows remote access

Source: Internet
Author: User

MySQL has no password by default. Enter mysql-u root to enter MySQL.

1. initialize the root password

Enter the MySQL database

 
Mysql> Update user SET Password = PASSWORD ('000000') where user = 'root ';

2. To allow remote access to MySQL, you can use the following three methods:

A. Change the table.

 
Mysql-u root-pmysql> use MySQL; mysql> Update user set host = '%' where user = 'root'; mysql> select host, user from user;

B. Authorization.

For example, you want the root user to use 123456 to connect to the MySQL server from any host.

 
Mysql> grant all privileges on *. * To 'root' @ '%' identified by '000000' with grant option;

If you want to allow Jack to connect to the MySQL server from a host with IP address 10.10.50.127 and use 654321 as the password

Mysql> grant all privileges on *. * To 'jack' @ '10. 10.50.127 'identified by '000000' with grant option; mysql> flush rivileges

C: run the following command on the machine where MySQL is installed:

 
// Enter MySQL Server D: \ mysql \ bin \> mysql-H localhost-u root // grant any host the permission to access data mysql> grant all privileges on *. * To 'root' @ '%' with grant option // make the modification take effect mysql> flush privileges // exit MySQL Server mysql> exit

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.