mysql创建数据库失败,提示ERROR 1044 (42000): Access denied for user 'huixin'@'localhost' to database '。。。##

## mysql创建数据库失败,提示ERROR 1044 (42000): Access denied for user 'huixin'@'localhost' to database '。。。##

C:\Windows\system32>mysql -h localhost -u huixin -p

Enter password: ******

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 25

Server version: 8.0.25 MySQL Community Server - GPL

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases ;

+--------------------+

| Database          |

+--------------------+

| information_schema |

+--------------------+

1 row in set (0.00 sec)

mysql> create database Mygod ;

ERROR 1044 (42000): Access denied for user 'huixin'@'localhost' to database 'myg

od'

mysql>

以上是我在写权限的时候报的错误,为啥会出现错误呢?

解决思路--

1,检查该用户的权限,是否开启创建数据库的权限

登录root 用户,检查 huixin 的Create_priv 权限是否为 N,如果是修改为N

alter table user set Create_priv ='Y' where user='huixin' ;

2,退出root用户, 登录 用户huixin  创建数据库 即可

mysql> show databases ;

+--------------------+

| Database          |

+--------------------+

| company            |

| index_test        |

| information_schema |

| market            |

| mygod              |

| mysql              |

| performance_schema |

| sys                |

+--------------------+

8 rows in set (0.00 sec)

你可能感兴趣的:(mysql创建数据库失败,提示ERROR 1044 (42000): Access denied for user 'huixin'@'localhost' to database '。。。##)