forget mysql root password in ubuntu

1. linux mysql的配置文件

windows下是my.ini
linux下是my.cnf

find / -name 你要找的文件(my.cnf)
mysql 的配置文件 在/etc/my.cnf 是对的

$ locate my.cnf
/etc/mysql/my.cnf

ls -l /etc/mysql/my.cnf
-rw-r–r– 1 root root 3504 Dec 7 20:01 /etc/mysql/my.cnf

修改MySQL的登录设置:
# vi /etc/my.cnf
在[mysqld]的段中加上一句:skip-grant-tables
例如:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-grant-tables 
保存并且退出vi。

  • :w!  若文件属性为只读,强制写入该文件
  • :wq  保存后退出,若为:wq!,则为强制保存后退出(常用)
  • o,O   插入新的一行:从光标所在处的下一行行首开始输入字符(常用)

重新启动mysqld/mysql

sudo /etc/init.d/mysql stop
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql stop

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) utility, e.g. stop mysql
mysql stop/waiting

sudo service mysql restart

Start mysql client

mysql -u root

Flush privileges and reset the password

mysql> USE mysql ; 
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> UPDATE user SET Password = password ( ‘new-password’ ) WHERE User = ‘root’ ; 
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0

mysql> flush privileges ; 
Query OK, 0 rows affected (0.01 sec)

mysql> quit

将MySQL的登录设置修改回来 

# vi /etc/mysql/my.cnf
将刚才在[mysqld]的段中加上的skip-grant-tables删除 
保存并且退出vi。

重新启动mysqld 

# /etc/init.d/mysqld restart

sudo service mysql restart

mysql stop/waiting
mysql start/running, process 18577

改变文件权限:

chmod go-rw xxx.xxx //表示删除xxx.xxx中组群和其他人的读和写的权限

  • u 代表所有者(user)
  • g 代表所有者所在的组群(group)
  • o 代表其他人,但不是u和g (other)
  • a 代表全部的人,也就是包括u,g和o
  •  +表示添加权限, – 表示删除权限,  = 表示使之成为唯一的权限

ERROR 1044 (42000): Access denied for user ”@’localhost’ to database ‘db’

via Linux平台:忘记mysql的root密码解决办法

Reset lost/forgot MYSQL root password ubuntu

2. Azure 强密码需要以下 4 项中的 3 项

  • 小写字符
  • 大写字符
  • 数字 (0-9)
  • 符号(请参阅前面提到的密码限制)

默认情况下,用户在更改其密码时需要创建强密码。 管理员能够通过 适用于 Windows Power Shell 的 Windows Azure Active Directory 模块在用户级别启用和禁用此设置。

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

生活在西班牙

自己动手丰衣足食

BlueAsteroid

Just another WordPress.com site

Jing's Blog

Just another WordPress.com site

Start from here......

我的心情魔方

天才遠私廚

希望能做一個分享各種資訊的好地方

语义噪声

西瓜大丸子汤的博客

笑对人生,傲立寰宇

Just another WordPress.com site

Where On Earth Is Waldo?

A Project By Melanie Coles

the Serious Computer Vision Blog

A blog about computer vision and serious stuff

Cauthy's Blog

paper review...

Cornell Computer Vision Seminar Blog

Blog for CS 7670 - Special Topics in Computer Vision

datarazzi

Life through nerd-colored glasses

Luciana Haill

Brainwaves Augmenting Consciousness

槑烎

1,2,∞

Dr Paul Tennent

and the university of nottingham

turn off the lights, please

A bunch of random, thinned and stateless thoughts around the Web

%d bloggers like this: