Linux下mysql数据库root无法登录的情况
今天安装lnmp环境后用mysql -u root -p连接密码后出现错误
Access denied for user 'root'@'localhost' (using password: YES)
然后我就用 /etc/init.d/mysql stop 先去停止数据库
然后用安全模式 mysqld_safe --user=mysql --skip-grant-tables --skip-networking & 进入数据库
然后用SQL语句修改root权限 UPDATE user SET Password=PASSWORD('我的密码') where USER='root';
改完了后 重新刷新权限 FLUSH PRIVILEGES; 然后quit退出
然后重启数据库就行了 /etc/init.d/mysql restart
[root@967b0e11e627 default]# mysql -u root -p
Enter password:
ERROR (): Access denied for user 'root'@'localhost' (using password: YES)
[root@967b0e11e627 default]# /etc/init.d/mysql stop
Shutting down MySQL. SUCCESS!
[root@967b0e11e627 default]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[]
[root@967b0e11e627 default]# :: mysqld_safe Logging to '/usr/local/mysql/var/967b0e11e627.err'.
:: mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var [root@967b0e11e627 default]# mysql -u root mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.5.-log Source distribution Copyright (c) , , Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
rows in set (0.02 sec) mysql> UPDATE user SET Password=PASSWORD('Weiwend&20150125') where USER='root';
Query OK, rows affected (0.00 sec)
Rows matched: Changed: Warnings: mysql> FLUSH PRIVILEGES;
Query OK, rows affected (0.00 sec) mysql> quit
Bye
[root@967b0e11e627 default]# /etc/init.d/mysql restart
Shutting down MySQL. :: mysqld_safe mysqld from pid file /usr/local/mysql/var/967b0e11e627.pid ended
SUCCESS!
Starting MySQL.. SUCCESS!
[]+ Done mysqld_safe --user=mysql --skip-grant-tables --skip-networking
[root@967b0e11e627 default]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.5.-log Source distribution Copyright (c) , , Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
rows in set (0.00 sec) mysql> exit
Bye
Linux下mysql数据库root无法登录的情况的更多相关文章
- linux下mysql数据库的操作
本文主要针对linux下mysql数据库的安装,以及数据库的创建和简单的数据库操作进行说明. ①.Mysql数据库的安装: 数据库的安装分为源码安装和rpm安装. 当然对于老手来说需要进行一些自定义的 ...
- linux下mysql忘记root密码怎么办
Linux下MySQL忘记root密码怎么办? Linux下MySQL忘记root密码怎么办? 1. 修改MySQL配置文件 默认MySQL的配置文件为/etc/my.cnf,在[mysqld]下面添 ...
- linux安装mysql后root无法登录 sql 无法登录
linux安装mysql后root无法登录 问题:[root@localhost mysql]# mysql -u root -pEnter password: ERROR 1045 (28000): ...
- Linux下MySQL数据库主从同步配置
说明: 操作系统:CentOS 5.x 64位 MySQL数据库版本:mysql-5.5.35 MySQL主服务器:192.168.21.128 MySQL从服务器:192.168.21.129 准备 ...
- 记录--linux下mysql数据库问题
本次主要记录一下linux下mysql数据库的一些问题,也是之前经常用到的知识,这里简单总结一些问题,方便自己以后的回顾.原来一直使用的是阿里云的RDS数据库mysql版,主要是因为上次阿里云做活动可 ...
- Linux下MySQL数据库的备份与恢复
Linux下MySQL数据库的备份与恢复 作者:Grey 原文地址: Github 语雀 博客园 基于版本 MySQL5.7 Deepin Linux 15.11 xtrabackup-2.4.18 ...
- Linux下Mysql数据库忘记root
系统环境:Red Hat Enterprise Linux Server 6 1.停止mysqld服务 [root@Server huage]# service mysqld stop 2.以跳过授权 ...
- Linux 下,mysql数据库报无法登陆错误:ERROR 1045 (28000): Access denied for use
今天在别人的服务器上登录mysql发现无法登陆(Mysql别人实现安装好的) 密码和用户名都是正确的,但登录后报如下错误: ERROR 1045 (28000): Access denied for ...
- Linux下MySQL 数据库的基本操作
1. 创建数据库相关命令: 首先,下载MySQL相关软件包:aptitude install mysql-server/mysql-client MySQL中的root用户类似于Linux下的root ...
随机推荐
- DOM Ready 详解
DOM Ready 概述 熟悉jQuery的人, 都知道DomReady事件. window.onload事件是在页面所有的资源都加载完毕后触发的. 如果页面上有大图片等资源响应缓慢, 会导致wind ...
- PHP设计模式之工厂/单例/注册者模式
工厂模式 简单工厂模式 [静态工厂方法模式](Static Factory Method)是类的创建模式 工厂模式的几种形态: 1.简单工厂模式(Simple Factory)又叫做 静态工厂方法模式 ...
- 【Asp.Net】小BUG汇总[更新]
目录结构 1.Dictionary<T>遍历 2.Asp.net网站部署在C盘无法上传下载文件 3.Asp.Net网站发布后远程无法访问 4.GDI+中发生一般性错误 1.Dictiona ...
- notepad++ :正则表达式系统教程
前言&索引 前言 正则表达式是烦琐的,但是强大的,学会之后的应用会让你除了提高效率外,会给你带来绝对的成就感.只要认真去阅读这些资料,加上应用的时候进行一定的参考,掌握正则表达式不是问题. 索 ...
- composer的create-project安装php框架laravel for mac教程
通过 Composer 的 create-project 命令安装 Laravel 通过在命令行执行 Composer 的 create-project 命令来安装Laravel: composer ...
- Codeforces Round #316 div2
一场充满血腥hack之战!!! Problem_A: 题意: n个候选人在m个城市进行投票,每个城市选出票数最多的一个候选人为城市候选人,如果票数相同,则取编号小的候选人. 再从这m个城市候选人中选出 ...
- bzoj 3823: 定情信物 线性筛逆元
3823: 定情信物 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 108 Solved: 2[Submit][Status] Descriptio ...
- WINDOWS WMI--这是一个神奇的应用
运行:wbemtest.exe
- [wikioi]乌龟棋
http://wikioi.com/problem/1068/ 多重背包.边界f[0,0,0,0]=a[1](初始时没有用任何卡片,获得棋盘第一格的分数)DP方程:f[i,j,k,l]=max(f[i ...
- HTML input标签的checked属性与Razor解析
在HTML中,input标签可以通过type属性设置为checkbox.同时,也就包含了一个checked属性.对于这个checked属性,有一个特别的地方就是,它可以不需要属性值就可以表示是否选择了 ...