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

Tutorial on installing and configuring remote login to MySQL under Ubuntu

This article shares the MySQL installation and co...

JavaScript implements front-end countdown effect

This article shares the specific code of JavaScri...

Vue3+TypeScript implements a complete example of a recursive menu component

Table of contents Preface need accomplish First R...

MySQL 5.7 installation-free configuration graphic tutorial

Mysql is a popular and easy-to-use database softw...

Tutorial on using $attrs and $listeners in Vue

Table of contents introduce Example Summarize int...

HTML tag dl dt dd usage instructions

Basic structure: Copy code The code is as follows:...

Causes and solutions for MySQL too many connections error

Table of contents Brief summary At noon today, th...

Vue parent component calls child component function implementation

Vue parent component calls the function of the ch...

How to use skeleton screen in vue project

Nowadays, application development is basically se...

Disabled values ​​that cannot be entered cannot be passed to the action layer

If I want to make the form non-input-capable, I se...

Detailed explanation of custom events of Vue components

Table of contents Summarize <template> <...

The easiest way to reset mysql root password

My mysql version is MYSQL V5.7.9, please use the ...