Home > Database > Mysql Tutorial > How to set up mysql to prohibit remote connections

How to set up mysql to prohibit remote connections

王林
Release: 2020-09-27 15:24:01
Original
5580 people have browsed it

Mysql settings prohibit remote connections: 1. Log in to the database server and specify the mysql database; 2. Execute the [update user set host='localhost' where user='root';] statement; 3. Refresh permissions surface.

How to set up mysql to prohibit remote connections

Specific steps:

(Recommended tutorial: mysql video tutorial)

use mysql                #打开mysql数据库
 
#将host设置为localhost表示只能本地连接mysql
 
update user set host='localhost' where user='root';
 
flush privileges;        #刷新权限表,使配置生效
Copy after login

If we To enable remote connection, you can refer to the following method:

First log in:

mysql -u root -h localhost -p
Copy after login
use mysql   
#打开mysql数据库#将host设置为%表示任何ip都能连接mysql,当然您也可以将host指定为某个ip
update user set host='%' where user='root' and host='localhost';flush privileges;        
#刷新权限表,使配置生效
Copy after login

After completion, we can connect to our mysql remotely.

Related recommendations: php training

The above is the detailed content of How to set up mysql to prohibit remote connections. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template