[root@teststd bin]# mysql Logging to file '/home/mysql/query.log' ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
怎么查看默认密码呢,可以在启动的日志里面,我是在error.log里面看到的。
[root@teststd mysql]# grep password *.log error.log:2016-11-09T14:28:51.344922+08:00 1 [Note] A temporary password is generated for root@localhost: aUpmj1zs8M%p error.log:2016-11-09T14:29:39.745255+08:00 2 [Note] Access denied for user 'root'@'localhost' (using password: NO) query.log:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
按照提示输入密码,就可以成功登录了。
[root@teststd mysql]# mysql -u root -p Logging to file '/home/mysql/query.log' Enter password: Welcome to the MySQL monitor. Commands end with ; or /g.
不过需要马上修改密码,要不什么命令都运行不了,会一直提示你修改密码。
> show databases; ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
[root@testdb2 ~]# mysqldump -f -hlocalhost -uroot --default-character-set=utf8 --single-transaction -R --triggers -q --all-databases |gzip> master.dmp.gz Warning: A partial dump from a server that has GTIDs will by default include the GTIDs of all transactions, even those that changed suppressed parts of the database. If you don't want to restore GTIDs, pass --set-gtid-purged=OFF. To make a complete dump, pass --all-databases --triggers --routines --events. 从库应用可能会有这样的错误。
# mysql < master.dmp Logging to file '/home/mysql/query.log' ERROR 1840 (HY000) at line 24: @@GLOBAL.GTID_PURGED can only be set when @@GLOBAL.GTID_EXECUTED is empty.
很简单,我们这是一个从库,show master应该不会有GTID的信息
> show master status/G *************************** 1. row *************************** File: mysql-bin.000005 Position: 194 Binlog_Do_DB: Binlog_Ignore_DB: Executed_Gtid_Set: c6d66211-a645-11e6-a2b6-782bcb472f63:1-135 1 row in set (0.00 sec)