发表于: 2017-04-04 21:52:22

2 1401


今天完成的任务:

   搞定了本地,远程云服务器又出毛病了,为了从本地用Navicat连接云服务器上的mysql,修改了云服务器上root的host地址,


原来地址:

mysql> select host,authentication_string,user,password_expired from user;

+-----------+-------------------------------------------+------------------+------------------+

| host      | authentication_string                     | user             | password_expired |

+-----------+-------------------------------------------+------------------+------------------+

| localhost | *3F74D540726A09115488CACC28311AA73C279580 | root             | N                |

| localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql.sys        | N                |

| localhost | *162D6F0294432AA3B01360F074383B4270BB152B | debian-sys-maint | N                |


修改后的地址

mysql> select host,authentication_string,user from user;

+---------------+-------------------------------------------+------------------+

| host          | authentication_string                     | user             |

+---------------+-------------------------------------------+------------------+

| 192.168.31.64 | *3F74D540726A09115488CACC28311AA73C279580 | root             |

| localhost     | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql.sys        |

| localhost     | *162D6F0294432AA3B01360F074383B4270BB152B | debian-sys-maint |

从localhost变为Navicat所在的本地电脑IP地址,结果就悲剧了,不但Navicat没有连接上,退出mysql后,再一次用secureCRT登录mysql也上不去了。报错:

root@VM-133-216-ubuntu:~# mysql -u root  -p 

Enten password:                                                                              

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




1.mysql 报错 Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

解决:mysql没有启动,service mysql start。


2.修改mysql密码报错

第一个错误:

root@VM-133-216-ubuntu:~# mysql -u root  -p 

Enten password:                                                                              

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

经查找资料发现是root帐户默认不开放远程访问权限,所以需要修改一下相关权限。

    解决方案:

打开MySQL目录下的my.ini文件,在文件的最后添加一行“skip-grant-tables”,保存并关闭文件。

重启MySQL服务。

通过命令行进入MySQL的BIN目录,或者在mysql目录下对bin文件夹“shift +右键”,然后选择在此处打开命令行窗口,打开后输入“mysql -u root -p”(不输入密码),回车即可进入数据库。

执行“use mysql;”,使用mysql数据库。

执行“update user set password=PASSWORD("123456") where user='root';”(修改root的密码,5.7以后版本没有password这个选项了,变成authentication_string)

打开MySQL目录下的my.ini文件,删除最后一行的“skip-grant-tables”,保存并关闭文件。

重启MySQL服务。

在命令行中输入“mysql -u root -p 123456”,即可成功连接数据库。

完成以上步骤,Navicat也可成功连接MySQL了。

 ubuntu命令行窗口下输入root@VM-133-216-ubuntu:~# mysqld_safe --skip-grant-tables &进行修改,后面的大致相同。


第二个错误:

root@VM-133-216-ubuntu:~# mysqld_safe --skip-grant-tables &

[1] 28296

root@VM-133-216-ubuntu:~# 2017-04-04T09:10:58.358279Z mysqld_safe Logging to syslog.

2017-04-04T09:10:58.360298Z mysqld_safe Logging to '/var/log/mysql/error.log'.

2017-04-04T09:10:58.362358Z mysqld_safe Logging to '/var/log/mysql/error.log'.

2017-04-04T09:10:58.364440Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists

解决:输入命令,再次进入mysqld_safe模式

mkdir -p /var/run/mysqld 

chown mysql:mysql /var/run/mysqld


第三个错误:

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

ERROR 1054 (42S22): Unknown column 'password' in 'field list'

解决:5.7版本的mysql没有该字段,用authentication_string .


第四个错误:

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

通过ps命令查看mysql进程即可,执行如下命令:

  ps -aux|grep mysql

  执行结果中看到了mysql进程,确定mysql正在运行。

root@VM-133-216-ubuntu:~# ps -aux|grep mysql

mysql     1644  0.0 17.9 1109940 158540 ?      Ssl  19:24   0:01 /usr/sbin/mysqld

root      2241  0.0  0.1  11284   972 pts/0    S+   20:23   0:00 grep --color=auto mysql

停止运行 kill  1644

本地cmd中远程连接服务器上的mysql,mysql -h 192.168.31.53 -P 3306 -u root -p(前面一个P要大写,表示端口);

实例入下:

C:\Users\Administrator>mysql -h 118.89.64.213 -P 3306 -u root -p

Enter password: **********

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

Your MySQL connection id is 51

Server version: 5.7.17-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2016, 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>

Linux下查看mysql的安装路径

root@VM-133-216-ubuntu:~# ps -ef|grep mysql

mysql     1644     1  0 19:24 ?        00:00:02 /usr/sbin/mysqld

root      2477  2136  0 21:00 pts/0    00:00:00 grep --color=auto mysql


3.云服务器运行Tomcat报错

bin/catalina.sh: 1: eval: {JAVA_HOME}/jre/bin/java: not found  

明天的计划:

   把JDK的环境变量从新配置,搞清楚/etc/profile、/etc/bashrc、~/.bashrc的区别,优化springMVC,改写controller,弄明白什么是restful.

遇到的问题:
   看似通路,从本地到远程,中间有很多关卡,背后支撑信息传输的协议,权限,有好几层。没有本地跑起来那么容易。

收获:

   远程连接,这应该是属于计算机几大板块里网络部分的内容,又一个新领域,过了一关又一关,学者如斯夫,不舍昼夜。加油!


返回列表 返回列表
评论

    分享到