一:登录报错

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. Sublime Text3中文乱码及tabs中文方块的解决方案

    一.文本出现中文乱码问题 方案1 1.打开Sublime Text 3,按Ctrl+-打开控制行,复制粘贴以下python代码,然后回车运行. 2. 复制并粘贴如下代码: import urllib. ...

  2. 面试题_82_to_87_Date、Time 及 Calendar 的面试题

    82)在多线程环境下,SimpleDateFormat 是线程安全的吗?(答案)不是,非常不幸,DateFormat 的所有实现,包括 SimpleDateFormat 都不是线程安全的,因此你不应该 ...

  3. 宏HASH_GET_NEXT

    /*******************************************************************//** Gets the next struct in a h ...

  4. ORACLE 如何定位消耗资源的SQL

    在分析SQL性能的时候,经常需要确定资源消耗多的SQL,总结如下: 1 查看值得怀疑的SQLselect substr(to_char(s.pct, '99.00'), 2) || '%' load, ...

  5. android的R.java

    R.java是个好东西,在Android程序开发过程中为你统一管理资源,添加ID,不可谓不犀利.不过有的时候好东西就越是娇贵,在写Android代码的时候,R.java频繁出错,搞得我是身心俱疲.数次 ...

  6. POJ 2481 Cows

    Cows Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 16546   Accepted: 5531 Description ...

  7. Storm实战常见问题及解决方案

    该文档为实实在在的原创文档,转载请注明: http://blog.sina.com.cn/s/blog_8c243ea30101k0k1.html 类型 详细 备注 该文档是群里几个朋友在storm实 ...

  8. linux下查看硬件配置的相关命令

    from:http://www.jakee.cn/index.php/archives/501.html 常用命令整理如下:查看主板的序列号: dmidecode | grep -i ’serial ...

  9. C++ STL算法系列3---求和:accumulate

    该算法在numeric头文件中定义. 假设vec是一个int型的vector对象,下面的代码: //sum the elements in vec starting the summation wit ...

  10. 总结c++ primer中的notes

    转载:http://blog.csdn.net/ace_fei/article/details/7386517 说明: C++ Primer, Fourth Edition (中英文)下载地址:htt ...