MySQL Authorized user remote Login

Source: Internet
Author: User
Tags mysql login

Because before the server has been directly operating MySQL, so did not encounter any problems, today development suddenly to test a function, need to connect the database, found to be connected not!

Because it's been a long time. mysql root password has been forgotten

Change root password under 1.linux

Vim/etc/my.cnf

Add a sentence to the paragraph in [mysqld]: Skip-grant-tables

Skip-grant-tables

Wq Save

/etc/init.d/mysqld Reatart #重启mysql服务

MySQL #登录mysql
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 3 to server version:3.23.56
Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the buffer.
mysql> use MySQL; #选择数据库
Database changed
mysql> UPDATE user SET Password = Password (' Password ') WHERE user = ' root ';
Query OK, 0 rows Affected (0.00 sec)
Rows matched:2 changed:0 warnings:0
mysql> flush Privileges;
Query OK, 0 rows affected (0.01 sec)
Mysql> exit

Bye #退出数据库

2. Prior to locatehost/127.0.0.1 authorization only, so to give any host access rights

Mysql-uroot-ppassword #以root用户登录mysql

Mysql>use DatabaseName #选择所要赋予权限的数据库

Mysql>grant all privileges on shandong.* to ' demo ' @ '% ' with GRANT OPTION #赋予任何主机的访问权限

mysql> flush Privileges;

Query OK, 0 rows affected (0.01 sec)
Mysql> exit

Bye #退出数据库

3. Change MySQL login settings back
# VI/ETC/MY.CNF
Delete the skip-grant-tables you just added in the paragraph [mysqld]
Restart Mysqld
#/etc/init.d/mysqld Restart
stopping MySQL: [OK]
Starting MySQL: [OK]

This article is from the "Technology House private Space" blog, please be sure to keep this source http://chulinx.blog.51cto.com/4098114/1742772

MySQL Authorized user remote Login

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.