Recently operating MySQL 5.6, the following issues have occurred.
Share, thanks to the original:
Case Environment:
Operating System: Red Hat Enterprise Linux Server release 5.7 (Tikanga)
Database version: Mysql 5.6.19-bit
Case Description:
Today began to learn MySQL, then installed the MySQL 5.6.19 64bit version of the database, the results were installed successfully, but using root login encountered error 1045 (28000): Access denied for user ' root ' loca Lhost ' (using Password:no) error. As shown below
[[email protected] tmp]
Preparing ... ########################################### [100%]
1:mysql-server ########################################### [100%]
[[email protected] tmp]
-bash:rmp:command not found
[[email protected] tmp]
Preparing ... ########################################### [100%]
1:mysql-client ########################################### [100%]
[[email protected] tmp] #/etc/rc.d/init.d/mysql Status
MySQL is not running[failed]
[[email protected] tmp] #/etc/rc.d/init.d/mysql Start
Starting MySQL. [ OK ]
[[email protected] tmp] # mysql-u Root-p
' Root ' @' localhost ' (using Password:no)
[[email protected] tmp] # mysql-u Root MySQL
' Root ' @' localhost ' (using Password:no)
Installation process has not set the root password, not clear the root password, search for some information on the Internet, there are some situations:
1: Some blogs say that Root's random password is in/root/.mysql_secret, but I don't have/root/.mysql_secret file in this version at all. Search for an article that has the following effect (no confirmation). It is not clear to me why this version did not generate this file?
ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:no): Indicates a temporary password without generating root
ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:yes): Represents a temporary password for root generation.
2: Some sources say Root's default password is empty, after confirming that it is old version, Mysql 5.6 and later release is in security consideration, root password is not empty.
In addition, I found that many people encountered similar problems in the website forum error 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:no)
Workaround:
First stop the MySQL server
[[email protected] INIT.D] #/etc/rc.d/init.d/mysql Stop
Shutting down MySQL. [OK]
Then use the Mysqld_safe command to start MySQL, update the root account password
--skip-grant-tables: Do not start grant-tables (authorization table), skip permission control.
--skip-networking: Skipping TCP/IP protocol, only native access (from some sources on the web, this option is not required.) Can not be used)
[[email protected] INIT.D] # Mysqld_safe--user=mysql--skip-grant-tables--skip-networking &
[2] 9396
[[email protected] INIT.D] # 140722 14:59:46 mysqld_safe Logging to '/var/lib/mysql/db-server.err '.
140722 14:59:46 Mysqld_safe starting mysqld daemon with databases From/var/lib/mysql
After executing the above command, this session window will appear unresponsive state, need to use CTRL + C to interrupt the session, check the/var/lib/mysql/db-server.err log, and found no other exception information. Did not figure out why the session window would appear unresponsive.
Tail-200/var/lib/mysql/db-server.err | More
' Binlog '
2014-07-22 14:59:41 9346 [Note]/usr/sbin/mysqld:shutdown complete
140722 14:59:41 mysqld_safe mysqld from PID File/var/lib/mysql/db-server.pid ended
140722 14:59:46 Mysqld_safe starting mysqld daemon with databases From/var/lib/mysql
2014-07-22 14:59:47 0 [Warning] TIMESTAMP with implicit the DEFAULT value is deprecated. Please use--explicit_defaults_for_timesta
For more details).
' Federated ' is disabled.
2014-07-22 14:59:47 9516 [Note] innodb:using Atomics to ref count buffer pool pages
2014-07-22 14:59:47 9516 [Note] innodb:the InnoDB memory heap is disabled
2014-07-22 14:59:47 9516 [Note] innodb:mutexes and rw_locks use GCC atomic builtins
2014-07-22 14:59:47 9516 [Note] innodb:compressed tables use zlib 1.2.3
2014-07-22 14:59:47 9516 [Note] innodb:using Linux native AIO
2014-07-22 14:59:47 9516 [Note] innodb:using CPU CRC32 Instructions
2014-07-22 14:59:47 9516 [Note] innodb:initializing buffer pool, size = 128.0M
2014-07-22 14:59:47 9516 [Note] innodb:completed initialization of buffer pool
2014-07-22 14:59:47 9516 [Note] innodb:highest supported file format is Barracuda.
2014-07-22 14:59:47 9516 [Note] innodb:128 rollback segment (s) is active.
For purge to start
2014-07-22 14:59:47 9516 [Note] innodb:5.6.19 started; Log sequence Number 1626087
for connections.
' 5.6.19 ' /var/lib/mysql/mysql.sock ' port:0 mysql Community Server (GPL)
-From user
, where user=' root ' and host=' root ' or host=' localhost ';
+-----------+------+-------------------------------------------+------------------+
| Host | User | Password | password_expired |
+-----------+------+-------------------------------------------+------------------+
| localhost | Root | *a848de7ccd839e924921bee41711991dda0d529e | Y |
+-----------+------+-------------------------------------------+------------------+
In Set (0.00 sec)
mysql> Update user Set Password=password (' p12#456 ')
, where user=' root ' and host=' root ' or host=' localhost ';
Query OK, 1 row Affected (0.00 sec)
Rows matched:1 changed:1 warnings:0
After setting up the user or changing the password, flush privileges will be required to flush the MySQL system permission related tables, otherwise access is denied, and another way is to restart the MySQL server for the new settings to take effect.
mysql> flush Privileges;
Query OK, 0 rows Affected (0.00 sec)
Mysql> quit
Bye
[[email protected] INIT.D] #/etc/rc.d/init.d/mysql Restart
Shutting down MySQL. 140722 15:02:27 mysqld_safe mysqld from PID File/var/lib/mysql/db-server.pid ended
[ OK ]
Starting MySQL. [ OK ]
[2]- done mysqld_safe--user=mysql--skip-grant-tables--skip-networking
[[email protected] INIT.D] # mysql-u Root P
' Root ' @' localhost ' (using Password:no)
[[email protected] INIT.D] # mysql-u Root-p
Welcome to the MySQL Monitor. end with; or \g.
Your MySQL Connection ID is 2
Server version:5.6.19
Copyright (c), the Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.
' \c ' to clear the current input statement.
In addition, if you log in to the MySQL database after executing the script encounter ERROR 1820 (HY000): You must set PASSWORD before executing this statement, can be used to reset the password to solve the problem.
mysql>Set Password = password (
At this point the problem is solved, but there are a lot of doubts, why this error? In fact, so much information is only to say the solution, but all avoided the cause of the problem.
Resources:
http://huangyifa163.blog.163.com/blog/static/262875752011127102215790/
http://sundful.iteye.com/blog/704337
Http://wenku.baidu.com/view/735ffa41be1e650e52ea995a.html
Http://www.cnblogs.com/sunson/articles/2172086.html
Http://blog.163.com/[email protected]/blog/static/164934572201081494343373/
Http://www.cnblogs.com/likai198981/archive/2013/04/06/3002518.html
Xiaoxiang Hidden Source: http://www.cnblogs.com/kerrycode/
Linux MySQL 5.6:error 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:no)