您的位置:首页 > 数据库 > MySQL

mysql ndbcluster设置root用户和远程登录

2015-12-10 18:05 549 查看
mysql ndbcluster设置root用户和远程登录

1.root用户不能登录

[root@ndbcluster2 ~]# mysql -uroot -p

Enter password:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

[root@ndbcluster2 ~]# mysql -uroot -p

Enter password:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

设置--skip-grant-tables跳过授权表认证

service mysqld stop

在配置文件中添加--skip-grant-tables(/etc/my.cnf)

service mysqld start

另外开个SSH连接

[root@localhost ~]# mysql

mysql>use mysql

mysql>update user set password=password("123456") where user="root";

mysql>flush privileges;

mysql>exit

去掉--skip-grant-tables重启mysql,root用户可以用设置的密码登录

设置root用户远程登录

GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

执行报如下错误,ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

[root@ndbcluster1 ~]# mysql -uroot -p

Enter password:

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

Your MySQL connection id is 2

Server version: 5.6.27-ndb-7.4.8-cluster-gpl

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

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>

mysql>

mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY 'root' WITH GRANT OPTION;

ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY 'root001' WITH GRANT OPTION;

ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

执行SET PASSWORD修改成功

mysql> SET PASSWORD = PASSWORD('root001');

Query OK, 0 rows affected (0.02 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY 'root' WITH GRANT OPTION;

Query OK, 0 rows affected (0.02 sec)

mysql>

FLUSH PRIVILEGES;

执行完成

远程连接测试,mysql集群节点,发现一个节点可以连接,一个节点不能连接

这个问题纠结很久 --由于对mysql集群不熟悉

原因上面的操作,没有在另外一个节点上执行导致的,mysql集群的用户认证是分开管理的,要两个节点都要执行

所以后创建用户要两个节点都执行
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: