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. thinkphp6使用验证器 信息如何输出到前端页面2. 在应用配置文件 app.php 中找不到’route_check_cache’配置项3. 如何判断数据库的库和表是否存在?4. 对于数字型SQL注入如何拦截?验证是否为数字能否有效?5. python - py2.7.12 + django1.11版 本机静态文件配置问题6. css - 手机浏览器的兼容问题,微信和其它下载的浏览器打开没有问题,谷歌也测试过,就是手机自带的浏览器有问题。7. linux - 如何暂停运行中python脚本8. mysql中的最大连接数就是请求数吗?那IOPS又表示什么意思呢?9. mysql - 多表关联查询的实现方法?10. 这是什么情况???
