fiona@fiona:~$ mysql -h 10.112.4.136
ERROR 1045 (28000): Access denied for user 'fiona'@'10.112.1.85' (using password: NO)
fiona@fiona:~$ mysql -h 10.112.4.136 -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'10.112.1.85' (using password: YES)
一直都在报错
使用mysql5.7
按照教程打开MySQL数据库远程访问的权限,报错依然没有解决
- 查看root权限,没有问题
mysql> show grants for 'root'@'%';
+-------------------------------------------------------------+
| Grants for root@% |
+-------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION |
+-------------------------------------------------------------+
1 row in set (0.00 sec)
- 怀疑密码不对,查看密码
发现5.7版本的列名不是password
mysql> select user,host,password from mysql.user;
ERROR 1054 (42S22): Unknown column 'password' in 'field list'
- 查看user列表,获得列名
mysql> desc mysql.user;
+------------------------+-----------------------------------+------+-----+-----
------------------+-------+
| Field | Type | Null | Key | Defa
ult | Extra |
+------------------------+-----------------------------------+------+-----+-----
------------------+-------+
| Host | char(60) | NO | PRI |
| |
| User | char(32) | NO | PRI |
| |
| Select_priv | enum('N','Y') | NO | | N
| |
| Insert_priv | enum('N','Y') | NO | | N
| |
| Update_priv | enum('N','Y') | NO | | N
| |
| Delete_priv | enum('N','Y') | NO | | N
| |
| Create_priv | enum('N','Y') | NO | | N
| |
| Drop_priv | enum('N','Y') | NO | | N
| |
| Reload_priv | enum('N','Y') | NO | | N
| |
| Shutdown_priv | enum('N','Y') | NO | | N
| |
| Process_priv | enum('N','Y') | NO | | N
| |
| File_priv | enum('N','Y') | NO | | N
| |
| Grant_priv | enum('N','Y') | NO | | N
| |
| References_priv | enum('N','Y') | NO | | N
| |
| Index_priv | enum('N','Y') | NO | | N
| |
| Alter_priv | enum('N','Y') | NO | | N
| |
| Show_db_priv | enum('N','Y') | NO | | N
| |
| Super_priv | enum('N','Y') | NO | | N
| |
| Create_tmp_table_priv | enum('N','Y') | NO | | N
| |
| Lock_tables_priv | enum('N','Y') | NO | | N
| |
| Execute_priv | enum('N','Y') | NO | | N
| |
| Repl_slave_priv | enum('N','Y') | NO | | N
| |
| Repl_client_priv | enum('N','Y') | NO | | N
| |
| Create_view_priv | enum('N','Y') | NO | | N
| |
| Show_view_priv | enum('N','Y') | NO | | N
| |
| Create_routine_priv | enum('N','Y') | NO | | N
| |
| Alter_routine_priv | enum('N','Y') | NO | | N
| |
| Create_user_priv | enum('N','Y') | NO | | N
| |
| Event_priv | enum('N','Y') | NO | | N
| |
| Trigger_priv | enum('N','Y') | NO | | N
| |
| Create_tablespace_priv | enum('N','Y') | NO | | N
| |
| ssl_type | enum('','ANY','X509','SPECIFIED') | NO | |
| |
| ssl_cipher | blob | NO | | NULL
| |
| x509_issuer | blob | NO | | NULL
| |
| x509_subject | blob | NO | | NULL
| |
| max_questions | int(11) unsigned | NO | | 0
| |
| max_updates | int(11) unsigned | NO | | 0
| |
| max_connections | int(11) unsigned | NO | | 0
| |
| max_user_connections | int(11) unsigned | NO | | 0
| |
| plugin | char(64) | NO | | mysq
l_native_password | |
| authentication_string | text | YES | | NULL
| |
| password_expired | enum('N','Y') | NO | | N
| |
| password_last_changed | timestamp | YES | | NULL
| |
| password_lifetime | smallint(5) unsigned | YES | | NULL
| |
| account_locked | enum('N','Y') | NO | | N
| |
+------------------------+-----------------------------------+------+-----+-----
------------------+-------+
45 rows in set (0.00 sec)
mysql> select user,host,authentication_string from mysql.user;
+-----------+-----------+-------------------------------------------+
| user | host | authentication_string |
+-----------+-----------+-------------------------------------------+
| root | localhost | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| root | % | *89C6B530AA78695E257E55D63C00A6EC9AD3E977 |
+-----------+-----------+-------------------------------------------+
3 rows in set (0.00 sec)
- 发现密码确实不是之前设置的root root,重置密码
mysql> set password for 'root'@'%' =password('root');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>
- 再次登录
fiona@fiona:~$ mysql -h 10.112.4.136 -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 49
Server version: 5.7.14-log MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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> exit
Bye
网友评论