[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)