Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

再入 MySQL 的门 #202

Open
Bpazy opened this issue Nov 4, 2021 · 2 comments
Open

再入 MySQL 的门 #202

Bpazy opened this issue Nov 4, 2021 · 2 comments

Comments

@Bpazy
Copy link
Owner

Bpazy commented Nov 4, 2021

用 MySQL 很久了,再一次记录一些问题

@Bpazy
Copy link
Owner Author

Bpazy commented Nov 4, 2021

root 用户无法给新用户授权

新创建了一个数据库,发现用 root 用户连上之后,无法给新创建的用户授权,提示 access denied for user 'root'@' ' to database 'behappy_prod'

调查后发现是 root 用户没有 grant 权限:

mysql> select host,user,grant_priv,super_priv from user;
+-----------+---------------+------------+------------+
| host      | user          | grant_priv | super_priv |
+-----------+---------------+------------+------------+
| localhost | mysql.session | N          | Y          |
| localhost | mysql.sys     | N          | N          |
| %         | root          | N          | Y          |
| %         | test          | N          | N          |
+-----------+---------------+------------+------------+

那么加上权限即可:

update mysql.user set Grant_priv='Y',Super_priv='Y' where user = 'root' and host = '%';
flush privileges;

注意需要重启 MySQL 服务: sudo systemctl restart mysql

@Bpazy
Copy link
Owner Author

Bpazy commented Oct 18, 2023

索引、字段类型和长度、新建表的话容量、数据库抖动、sql性能

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant