Ubuntu MySQL服务器 - 权限和用户问题

时间:2014-03-19 08:46:11

标签: mysql root privileges

我有一台运行MySQL的服务器,但“localhost”的“root”用户被误删了。 我重新安装了MySQL服务器。

我作为用户debian-sys-maint并且重新创建了用户“root”。 现在,我有以下用户:

+-----------+------------------+
| host      | user             |
+-----------+------------------+
| %         | root             |
| 127.0.0.1 | root             |
| srvname   | root             |
| localhost | debian-sys-maint |
| localhost | root             |
+-----------+------------------+

但如果我跑:

> grant all privileges on *.* to "root"@"localhost" identified by "password";

GOT:

ERROR 1045 (28000): Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)

更新#1

以用户“root”身份登录。

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| multitest          |
| mysql              |
+--------------------+
3 rows in set (0.00 sec)

mysql> use mysql;
Database changed
mysql> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| func                      |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| proc                      |
| procs_priv                |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+

更新#2

这是我当前用户的表格:

+-----------+------------------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+
| Host      | User             | Password                                  | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Show_db_priv | Super_priv | Create_tmp_table_priv | Lock_tables_priv | Execute_priv | Repl_slave_priv | Repl_client_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Create_user_priv | ssl_type | ssl_cipher | x509_issuer | x509_subject | max_questions | max_updates | max_connections | max_user_connections |
+-----------+------------------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+
| Euler     | root             | *D52773855DC0243707A56F7D93CDBC483C3CC2FD | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          | Y            | Y          | Y                     | Y                | Y            | Y               | Y                | Y                | Y              | Y                   | Y                  | Y                |          |            |             |              |             0 |           0 |               0 |                    0 |
| 127.0.0.1 | root             | *D52773855DC0243707A56F7D93CDBC483C3CC2FD | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          | Y            | Y          | Y                     | Y                | Y            | Y               | Y                | Y                | Y              | Y                   | Y                  | Y                |          |            |             |              |             0 |           0 |               0 |                    0 |
| localhost | debian-sys-maint | *9C9844E6DBB297FA7E3AF554FBCC21096F159437 | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          | Y            | Y          | Y                     | Y                | Y            | Y               | Y                | N                | N              | N                   | N                  | N                |          |            |             |              |             0 |           0 |               0 |                    0 |
| localhost | root             | *D52773855DC0243707A56F7D93CDBC483C3CC2FD | N           | N           | N           | N           | N           | N         | N           | N             | N            | N         | Y          | N               | N          | N          | N            | Y          | N                     | N                | N            | N               | N                | N                | N              | N                   | N                  | N                |          |            |             |              |             0 |           0 |               0 |                    0 |
| %         | root             | *D52773855DC0243707A56F7D93CDBC483C3CC2FD | N           | N           | N           | N           | N           | N         | N           | N             | N            | N         | Y          | N               | N          | N          | N            | Y          | N                     | N                | N            | N               | N                | N                | N              | N                   | N                  | N                |          |            |             |              |             0 |           0 |               0 |                    0 |
+-----------+------------------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+

1 个答案:

答案 0 :(得分:0)

解决。

在查看我的用户表后,我运行UPDATE命令,让任何“root”使用所有可用的权限。