首先,报错那个
可以登陆,但是无论我输入什么都会报错:
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> use test;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> select version();
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user user() identified by "123456";
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> SET PASSWORD = PASSWORD('123456');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
翻译一下,1820的报错是你必须重置你的密码什么什么的;1819的报错是你的密码不符合它的规范。大概这个意思。
接下来先解决这个问题:
mysql -u root -p
输入密码登陆
然后输入下面语句
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)
mysql> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.02 sec)
你可以发现你可以实行语句了
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.10 sec)
这拒绝了第一个问题,第二个问题是无法连接远程服务器,这其中一种可能就是你没有设置服务器里面的3036端口,这个你买的服务器里面有教你怎么设置的。接下来我要讲的的没有权限这种可能:
你要给你的哪个用户设置远程的权限:
我这个是给root这个用户赋予权限
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)
刷新:mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
查看
mysql> SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
+------------------------------------+
| query |
+------------------------------------+
| User: 'root'@'%'; |
+------------------------------------+
5 rows in set (0.00 sec)
即能你刚刚设置的。
然后你再本地上连接服务器,输入名字跟密码,就能登陆了:
服务器端口设置: