授予 MariaDB 权限 [英] Grant privileges on MariaDB

查看:40
本文介绍了授予 MariaDB 权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为 MariaDB 10 上的用户授予权限,但出现错误 1045

I'm trying to grant privileges for user on MariaDB 10, but I've got an error 1045

[root@lw343 ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 42
Server version: 10.0.11-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, SkySQL Ab and others.

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


MariaDB [mysql]> select user,host from mysql.user;                              
+--------+-----------+
| user   | host      |
+--------+-----------+
| ruser  | %         |
| root   | 127.0.0.1 |
| bill   | localhost |
| nagios | localhost |
| root   | localhost |
+--------+-----------+
5 rows in set (0.00 sec)

MariaDB [mysql]> select user(),current_user();
+----------------+----------------+
| user()         | current_user() |
+----------------+----------------+
| root@localhost | root@localhost |
+----------------+----------------+
1 row in set (0.00 sec)

MariaDB [mysql]> show variables like 'skip_networking';                         
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| skip_networking | OFF   |
+-----------------+-------+
1 row in set (0.00 sec)

MariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO root@"localhost" IDENTIFIED BY '**********' WITH GRANT OPTION;
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
MariaDB [mysql]>

我已经尝试了我在互联网上找到的所有内容,但我遇到了同样的错误.我也尝试创建新用户,但我尝试授予的每个用户仍然遇到相同的错误.

I have tried all what I found on the internet, but I've got the same error. I also tried creating new user, but I still got same error on every user I try to grant on.

有人可以帮我解决这个问题吗?

Does anybody could help me to resolve this problem?

提前致谢.

推荐答案

首先我会检查数据库服务器是否正在监听网络.

First of all i would check if the database server is listening on the network.

netstat -tlpn | grep mysql

我希望是这样的:

tcp        0      127.0.0.1:3306              0.0.0.0:*                   LISTEN 

如果数据库服务器正在侦听 127.0.0.1:3306,则仅允许从 localhost 进行连接.更改50-server.cnf中的以下行并重新启动数据库服务(service mariadb restart).

If the database server is listening on 127.0.0.1:3306, connection are allowed only from localhost. Change the following lines in 50-server.cnf and restart the database service (service mariadb restart).

bind-address = 0.0.0.0

  • 使用 bind-address
  • 允许监听多个网络接口或特定 IP 地址

    • Permit listening on multiple network interfaces or a specific IP address with bind-address
    • 您的 mysql.user 表显示用户 root 只能从 localhost127.0.0.1 连接.

      Your mysql.user tables shows that user root can connect only from localhost and 127.0.0.1.

      如果您需要一个可以从任何地方连接到数据库的远程用户(@'%'),具有 root 权限,您可以创建另一个超级用户.

      If you need a remote user, that can connect to database from everywhere (@'%'), with root privileges, you can create another superuser.

      GRANT ALL PRIVILEGES ON *.* TO 'superuser'@'%' IDENTIFIED BY 'use_a_secure_password';
      

      现在超级用户拥有与默认 root 帐户相同的权限,请注意!

      Now superuser has the same privileges as the default root account, beware!

      作为对用户权限进行任何更新后的最后一步:

      As a final step following any updates to the user privileges:

      FLUSH PRIVILEGES;
      

      我还注意到您的 mysql.user 表显示了一个可以通过网络连接的用户 ruser.

      Also i notice that your mysql.user tables shows a user ruser that can connect over the network.

      有用的资源:

      您还可以查看以下答案:https://stackoverflow.com/a/16288118/3095702

      You may also check following answer: https://stackoverflow.com/a/16288118/3095702

      这篇关于授予 MariaDB 权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆