devroom.io/content/posts/2010-10-26-clear-your-mysql-password.md

34 lines
1.2 KiB
Markdown
Raw Normal View History

2017-03-20 15:35:19 +00:00
+++
date = "2010-10-26"
title = "Clear your MySQL password"
tags = ["MySQL", "development", "password"]
slug = "clear-your-mysql-password"
+++
2015-03-26 11:28:08 +00:00
Most people need their MySQL database protected with at least a decent password. I agree, but in development this often causes conflicts - and I prefer to work with my MySQL datbase without all the password-hassle.
On Ubuntu I recently installed MySQL and set a password. Here's how to remove that password so you can skip all the password stuff during development.
~
First, connect to MySQL and check what permissions are currently set:
2017-03-20 15:35:19 +00:00
``` shell
$ mysql -u root -p
use mysql;
select Host, User, Password from user;
```
2015-03-26 11:28:08 +00:00
You'll probably see three entries for the `root` user: `localhost`, `127.0.0.1` and your hostname like `hostname`. To clear the password for the root user issue the following query:
2017-03-20 15:35:19 +00:00
``` sql
update user set password = '' where user = 'root';
```
2015-03-26 11:28:08 +00:00
Optionally, you may only want to reset the password for `localhost`:
2017-03-20 15:35:19 +00:00
``` sql
update user set password = '' where user = 'root' and host = 'localhost';
```
2015-03-26 11:28:08 +00:00
Keep in mind that using no MySQL password is insecure. Always protected your MySQL database with at least a strong password in production.
2017-03-20 15:35:19 +00:00