当前位置:网站首页>Mysql database remote access permission settings
Mysql database remote access permission settings
2022-07-02 10:44:00 【Software testing Xiaobai】
MySQL Database remote access permission settings
For beginners , We installed mysql Local service , Then use some graphical tools to link . Generally, we can link successfully ; however 、 In a simulated real environment, our database cannot be directly installed on the local machine , Most of them are on cloud servers , In this case, our mysql Nor is it a roadside bus that waves and stops , You still offered ( Buy tickets first !); That is, your account is not allowed to log in remotely , Only in localhost Sign in , What do I do ?
Next, I will explain two simple methods 、 The simplest method is to log in with an administrator account , In this way, you can modify
Let's login first mysql
One 、 Change table ( Of course, we need to know where the watch is first , Applicable to the entire database )
• show databases;# Display all databases
• use mysql;# Use mysql database
• show tables;# To find the user surface


• select * from user;# View all the information in this table

We can clearly identify the corresponding host ; Users and user permissions
1、 Directly modifying
update user set host = '%' where user = 'root';# to update root The user's host access is any value
2、 Add specified users and specified permissions
insert into user(host,user) values('ip','user');# Add a user user Address ip Unauthorized user of ( When you can insert new user information , Incidentally, check the authority , There will be an alarm during execution , Because there are constraints in the table , Don't go into it )

Added successfully , But I don't have permission .
Two 、 to grant authorization
• Direct authorization (mysql8.0 The version will report an error , Grammatical segmentation )
grant all privileges on *.* to 'user'@'ip' identified by '123456';# The authorization to the host is ip Of user Open to users , All permissions of all databases and corresponding tables , And the password is set to 123456( Fast and simple )
• Direct authorization ( Change - For the new version )
create user ‘user’@‘ip’ identified by ‘123456’;# Create a host address that is ip Login password is 123456 Of user user
grant all privileges on *.* to 'user'@'ip';# Link to the previous step , Give him all authority

• Specify authorization
create user ‘mysql’@‘%’ identified by ‘123456’;# When creating a host address, the login password of any address is 123456 Of mysql user ( Whenever and wherever possible , Login anywhere )
grant select,create on myemployees.* to 'mysql'@'%';# Set up mysql Users only use myemployees Check of Library , Create permissions

flush privilege;# Refresh the data permission
in the light of mysql8.0 An error will be reported when operating above version and cannot be linked ;
8.0 Because of the change of password rules and syntax rules , So set it again
In the same case, execute the following statements in sequence
alter user ‘mysql’@‘%’ identified by ‘123456’ passwore expire never;# Modify encryption rules
alter user ‘mysql’@‘%’ identified by ‘123456’ mysql_native_password by '123456';# Reset the password again
flush privilege;# Refresh the data permission


Try to link it with tools !
welfare

边栏推荐
猜你喜欢

14.信号量的代码实现

Post disaster reconstruction -- Floyd thought

Basic usage of mock server

Stm32 et développement de moteurs (système supérieur)

(五)APA场景搭建之挡位控制设置

Postman -- use

Redis set password

This article takes you to learn in detail what is fiber to home FTTH

Flink calculates topn hot list in real time

数据库字典Navicat自动生成版本
随机推荐
1287_FreeRTOS中prvTaskIsTaskSuspended()接口实现分析
合并有序数列
Database dictionary Navicat automatic generation version
Sum the two numbers to find the target value
618再次霸榜的秘密何在?耐克最新财报给出答案
【虚幻4】从U3D到UE4的转型之路
面对不确定性,供应链的作用
【MySQL】连接MySQL时出现异常:Connection must be valid and open
Blender model import UE, collision settings
Importing tables from sqoop
Transport Optimization abstraction
2021-10-04
[pit avoidance guide] pit encountered using ugui: the text component cannot indent the first line by two spaces
Basic usage of mock server
SQOOP 1.4.6 INSTALL
What are the popular frameworks for swoole in 2022?
Feature (5): how to organize information
【Lua】常见知识点汇总(包含常见面试考点)
Postman--使用
flume 190 INSTALL