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 tutorial on setting password for MySQL free installation version

Method 1: Use the SET PASSWORD command MySQL -u r...

Pure CSS3 to create page switching effect example code

The one I wrote before is too complicated, let’s ...

How to install Nginx in a specified location in Centos system

How to install Nginx in a specified location in C...

Solution to blank page after Vue packaging

1. Solution to the problem that the page is blank...

Create a screen recording function with JS

OBS studio is cool, but JavaScript is cooler. Now...

How to get/calculate the offset of a page element using JavaScript

question By clicking a control, a floating layer ...

Some findings and thoughts about iframe

This story starts with an unexpected discovery tod...

Tips to prevent others from saving as my web page and copying my site

Nowadays, copying websites is very common on the I...

Introduction to Semantic XHTML Tags

The first point to make is that people can judge t...

VMwarea virtual machine installation win7 operating system tutorial diagram

The installation process of VMwarea will not be d...

MySQL Series 4 SQL Syntax

Table of contents Tutorial Series 1. Introduction...

Detailed explanation of the process of modifying Nginx files in centos7 docker

1. Install nginx in docker: It is very simple to ...

Font Treasure House 50 exquisite free English font resources Part 2

Designers have their own font library, which allo...