yum - linux7.0安裝mysql的問題
問題描述
安裝mysql
# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm# rpm -ivh mysql-community-release-el7-5.noarch.rpm# yum install mysql-community-server
啟動mysqlservice mysqld restart設置密碼
[root@YFPUNzLr ~]# mysql -urootERROR 1045 (28000): Access denied for user ’root’@’localhost’ (using password: NO)
可我沒設置密碼啊,網上找了幾個方式都沒用。
問題解答
回答1:網上找到的有效答案:密碼在/var/log/mysqld.log這個文件里可以用grep ’temporary password’ /var/log/mysqld.log來查詢,也可以自己在文件里找。
[root@YFPUNzLr ~]# grep ’temporary password’ /var/log/mysqld.log2017-02-15T14:31:05.449058Z 1 [Note] A temporary password is generated for root@localhost: 3NeI3PuNwa%j[root@YFPUNzLr ~]# mysql -uroot -pEnter password: Welcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 10Server version: 5.7.17Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ’help;’ or ’h’ for help. Type ’c’ to clear the current input statement.mysql> 回答2:
不知道你的MySQL版本和系統版本是多少。多少。如果是5.7的話,可能在日志文件里面有記錄。如果日志文件里面沒有,可以重設密碼的,不需要重新安裝的。MySQL 5.7.6 以及最新版本:
vim /etc/my.cnf# 添加下面的字段skip-grant-tables mysql> update user set mysql>authentication_string=PASSWORD(’123456’) where User=’root’;mysql>flush privileges;
以前的版本,
vim /etc/my.cnf# 添加下面的字段skip-grant-tables mysql> use mysql;mysql> update user set password=PASSWORD('password') where User=’root’; mysql> flush privileges; 回答3:
看一下錯誤日志,應該有個password的字段,后面跟著一串奇怪的東西就是密碼如果沒有就重置密碼吧
回答4:薛定諤的密碼……
你應該是安裝時設置密碼了 如果忘了的話就卸載重新安吧 如果還是不行去看一下mysql日志 看看有什么報錯沒 再不行就百度mysql忘記密碼看怎么強制修改
回答5:默認密碼有可能保存在文件~/.mysql_secret中。
回答6:mysql默認root密碼是空的。
登錄用mysql -u root -p
另外你可以執行以下 mysql_secure_insatllation 設置密碼
相關文章:
1. mac OSX10.12.4 (16E195)下Mysql 5.7.18找不到配置文件my.cnf2. mysql - 數據庫表中,兩個表互為外鍵參考如何解決3. 在mybatis使用mysql的ON DUPLICATE KEY UPDATE語法實現存在即更新應該使用哪個標簽?4. mysql - 數據庫建字段,默認值空和empty string有什么區別 1105. mysql儲存json錯誤6. sql語句 - 如何在mysql中批量添加用戶?7. mysql - 表名稱前綴到底有啥用?8. php - 公眾號文章底部的小程序二維碼如何統計?9. Navicat for mysql 中以json格式儲存的數據存在大量反斜杠,如何去除?10. mysql - 怎么生成這個sql表?
