Solve the problem of Access denied for user 'root'@'%' to database 'xxx' after creating a database in MySQL

Solve the problem of Access denied for user 'root'@'%' to database 'xxx' after creating a database in MySQL

Preface

I recently encountered a problem at work. After creating the database, an error occurred when connecting to the database. The error code was Access denied for user 'root'@'%' to database 'xxx'. I finally solved this problem by searching for relevant information. So I thought of summarizing it and sharing it with friends in need for reference and study. Let's take a look together.

Solution process

1. Create a database

create database mytest;

2. Connect to the database and report the following error:

Access denied for user 'root'@'%' to database 'mytest'

Reason: After creating the database, authorization is required. This problem generally does not occur when accessing locally.

3. Authorize database operations

grant all on xxx.* to 'root'@'%' identified by 'password' with grant option;

Among them: xxx represents the created database; password is the user password, which is the root password in this case.

Summarize

The above is the full content of this article. I hope that the content of this article can bring some help to your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support of 123WORDPRESS.COM.

You may also be interested in:
  • Solve the problem of Django writing Chinese characters to MySQL
  • Solution to the error of inserting Chinese characters into MySQL under centOS7
  • How to avoid garbled characters when accessing Chinese characters in C# and MySQL
  • Example of how to create a local user in mysql and grant database permissions
  • How to create a MySQL database and support Chinese characters

<<:  Implementing Binary Search Tree in JavaScript

>>:  Solution to uninstalling Python and yum in CentOs system

Recommend

Detailed explanation of the middleman mode of Angular components

Table of contents 1. Middleman Model 2. Examples ...

JS achieves five-star praise effect

Use JS to implement object-oriented methods to ac...

Vue encapsulation component tool $attrs, $listeners usage

Table of contents Preface $attrs example: $listen...

Analysis of Hyper-V installation CentOS 8 problem

CentOS 8 has been released for a long time. As so...

A brief discussion on the three major issues of JS: asynchrony and single thread

Table of contents Single thread asynchronous Sing...

How to Monitor Linux Memory Usage Using Bash Script

Preface There are many open source monitoring too...

Example of how to enable Brotli compression algorithm for Nginx

Brotli is a new data format that can provide a co...

Detailed explanation of keepAlive usage in Vue front-end development

Table of contents Preface keep-avlive hook functi...

jQuery implements font size adjustment case

This article shares the specific code of jQuery t...

Implementation of two basic images for Docker deployment of Go

1. golang:latest base image mkdir gotest touch ma...

How to solve the problem of forgetting the root password of Mysql on Mac

I haven't used mysql on my computer for a lon...

Simple use of Vue bus

Simple use of Vue bus Scenario description: Compo...

MySQL FAQ series: When to use temporary tables

Introduction to temporary tables What is a tempor...

Several methods of deploying multiple front-end projects with nginx

I have summarized 3 methods to deploy multiple fr...

Introduction and analysis of three Binlog formats in MySQL

one. Mysql Binlog format introduction Mysql binlo...