sql - 在MariaDB上授予特权

标签 sql root mariadb grant mysql-error-1045

我正在尝试为MariaDB 10上的用户授予特权,但出现错误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]>


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

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

提前致谢。

最佳答案

好的,因此,首先了解用户是作为用户名/主机名组合创建的。因此root@localhostroot@192.168.1.5不同。对于远程连接,您不能使用root@localhost,因为这是用于从localhost连接的

因此,创建另一个用户。

其次,如果root@localhost已经存在,则不要使用identified by,因为您已经有密码...。

关于sql - 在MariaDB上授予特权,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27130069/

相关文章:

mysql - UTF-8字符有问题;我看到的不是我存储的

mysql - SQL - MAX 值不符合适当的值

sql - 查找在不同入职日期雇用的员工姓名

mysql - 在另一个表中复制数据以提高性能

android - 更新后如何重启自包

php - 从 PHP 调用的查询中的 MySQL (MariaDB) 执行超时

php - mysql查询中的二维数组

macos - Mac 终端中的 update_dyld_shared_cache 错误

root - adb 和 fastboot 错误 : remote: partition table doesn't exist while flashing twrp. img

mysql - MariaDB 没有 ST_Distance_Sphere 的等效函数