redhat5下安裝MySQL-5.6,默認裝完沒有設置mysql的密碼,按理說應該mysql的root用戶的默認密碼爲空,但是默認空密碼無法進入,報錯信息如下:
Access denied for user 'root'@'localhost' (using password: NO)
各種密碼嘗試都無法進入mysql。經網上查找資料終於找到解決辦法。
解決辦法:
找到my.cnf文件,編輯文件,添加如下內容:
skip-grant-tables
skip-networking
紅色字體爲新添加。
[root@localhost /]# vi /usr/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
[mysqld]
[color=red]
skip-grant-tables
skip-networking
[/color]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = .....
重新啓動:/etc/init.d/mysql restart
啓動OK後,mysql的root用戶默認空密碼可以正常進入。
轉自http://jadethao.iteye.com/blog/1922991