一:登录报错

ERROR 1045 (28000): Access denied for user 'mysql'@'localhost' (using password: NO)
mysql日志文件总结此问题的整体步骤如下:
第一步:修改pid路径
查看日志文件中错误信息:
cat /var/log/mysqld.log
2013-10-26 16:39:34 3712 [ERROR] /usr/sbin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2 - No such file or directory)
2013-10-26 16:39:34 3712 [ERROR] Can't start server: can't create PID file: No such file or directory
原因:
mysql 用户没有操作/var/run目录的权限,所以pid文件无法创建,导致登陆时无法建立 进程信息文件,登陆进程就无法开启,自然无法登陆。
解决:
修改 /etc/my.conf
原来为:
#pid-file=/var/run/mysqld/mysqld.pid
修改为
pid-file=/var/lib/mysql/mysqlid.pid
检查发现,mysql用户根本无法cd到/var/run/。修改为mysql可以有权限的目录后再执行mysql就进入数据库了。
第二步:修改数据库默认密码
/etc/init.d/mysql stop   (service mysqld stop)
/usr/bin/mysqld_safe --skip-grant-tables
另外开个SSH连接
[root@localhost ~]# mysql
mysql>use mysql
mysql>update user set password=password("123456") where user="root";
mysql>flush privileges;
mysql>exit
然后
[mysql@localhost etc]$ ps -A | grep mysql
4532 pts/0    00:00:00 mysqld_safe
5542 pts/0    00:00:00 mysqld
[mysql@localhost etc]$ kill -9 4532 5542
正常启动 MySQL:/etc/init.d/mysql start   (service mysqld start)
第三步:
登陆ok。 mysql -uroot -p
二:远程登录mysql数据库报错

ERROR 1130 (HY000): Host '192.168.76.50' is not allowed to connect to this MySQL server
1.改表法。
可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"
mysql -u root -pTalent123
mysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>select host, user from user;
mysql> flush privileges;
2.授权法。
例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
如果你想允许用户myuser从ip为192.168.1.3的主机连接到mysql服务器,并使用mypassword作为密码
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY
'mypassword' WITH GRANT OPTION;
三:创建普通用户后无法在本地登录
[root@jcfx-4 ~]#mysql -h192.168.76.73 -usalt -psalt
ERROR 1045 (28000): Access denied for user 'salt'@'jcfx-4' (using password: YES)
通过查看user表发现localhost对应的是空密码,所以这是导致不能再本地登录的根本原因:
mysql> select host,user,password from mysql.user;
解决方法:
mysql> grant select,insert,update,delete on salt.* to salt@"localhost" identified by "salt";
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
四:mysql登录报错:

[root@patronus2 bin]# mysql
-bash: mysql: command not found
解决方法:
ln -s /usr/local/mysql/bin/mysql /usr/bin
五:设置字符集

Server version: 5.6.21 MySQL
character_set_server=utf8
注:遇到异常情况,通过上面列举的办法应该是可以解决;

Mysql常见报错解决方法的更多相关文章

  1. 03:git常见报错解决方法

    1.1 git常见报错解决方法 1.warning: LF will be replaced by CRLF in .idea/workspace.xml. 参考博客:https://www.cnbl ...

  2. React 开发常见报错解决方法

    1. 使用 redux 的异步 action 时浏览器报错: Error: Actions must be plain objects. Use custom middleware for async ...

  3. tomcat常见报错解决方法汇总

    报错一:内存泄漏,字眼This is very likely to create a memory leak. 解决方法:修改tomcat内存. 在tomcat/bin目录下,修改catalina.s ...

  4. js常见报错解决方法

    1.获得类名document.getElementsClassName(常出现一个问题): getClassName("gn","pt")[0].appendC ...

  5. Docker常见报错解决方法记录

    [问题一]OCI runtime exec failed......executable file not found in $PATH": unknown [root@localhost ...

  6. Django 连接 MySQL 数据库及常见报错解决

    目录 Django 连接 MySQL数据库及常见报错解决 终端或者数据库管理工具连接 MySQL ,并新建项目所需数据库 安装访问 MySQL 的 Python 模块 Django 相关配置 可能会遇 ...

  7. MySQL常见报错汇总

    1>.ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it canno ...

  8. jdbc+mysql常见报错总结

    1.The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You ...

  9. Mysql 常见报错和疑问汇总

    1.初始化数据库的时候报错 error while loading shared libraries: libstdc++.so.5: cannot open shared object file:  ...

随机推荐

  1. Qt之自定义界面(窗体缩放)

    简述 通过前两节内容,我们实现了自定义窗体的移动,以及自定义标题栏-用来显示窗体的图标.标题,以及控制窗体最小化.最大化.关闭. 在这之后,我们还缺少窗体的缩放-当鼠标移动到窗体的边框-左.上.右.下 ...

  2. Deferred的那些知识

    在移动开发中的各种中,我们一定会遇到异步回调的问题,比如: 1:Css3执行动画完毕, 回调 2:Jquery Animate动画的执行完毕, 回调 3:Ajax的执行(并行.串行),回调 等等   ...

  3. 永久的CheckBox(单选,全选/反选)!

    <html> <head> <title>选择</title> <script type="text/javascript" ...

  4. 实现一个基于FTP协议的程序——文件上传下载器(十三)

    此为一个系列,后续会把内容补上...

  5. codeforces 333B - Chips

    注意:横向纵向交叉时,只要两条边不是正中的边(当n&1!=1),就可以余下两个chip. 代码里数组a[][]第二维下标 0表示横向边,1表示纵向边. #include<stdio.h& ...

  6. UVA 820 Internet Bandwidth 因特网宽带(无向图,最大流,常规)

    题意:给一个无向图,每条边上都有容量的限制,要求求出给定起点和终点的最大流. 思路:每条无向边就得拆成2条,每条还得有反向边,所以共4条.源点汇点已经给出,所以不用建了.直接在图上跑最大流就可以了. ...

  7. dagli最早干了这样一件事儿 Localization of Cardiac-Induced Signal Change in fMRI

    Localization of Cardiac-Induced Signal Change in fMRI 这篇文章是最早做生理噪声相关组织的定位的. 很奇特,因为,这位学者甚至得出了,血管心动等变化 ...

  8. 【C#学习笔记】获得本机IP

    using System; using System.Net; namespace ConsoleApplication { class Program { static void Main(stri ...

  9. Darwin Streaming server 的 Task 类

    Darwin Streaming Server 是一个开放源代码的streaming server,对于streaming server的编程和软件结构有着一定的参考价值,它是使用C++写的,其中的并 ...

  10. [转] C#中发送消息给指定的窗口,以及接收消息

    原文C#中发送消息给指定的窗口,以及接收消息 public class Note { //声明 API 函数 [DllImport("User32.dll", EntryPoint ...