How can I delete my password for MySQL? I dont want to have a password to connect to the database. My server is running Ubuntu.
Personally, I think instead it's better to set a password and save it in /root/.my.cnf:
mysqladmin -u root password 'asdfghjkl'
Then edit root's .my.cnf file:
[client] password = asdfghjkl
Make sure to
chmod 0600 .my.cnf.
Now you have a password but you're no longer prompted for it. My default MySQL server install is a totally random unique password for each MySQL server, saved in the .my.cnf file like this.
Yes, less passwords can be a good thing. But don't just open the database for everybody.
grant usage on *.* to 'root'@'localhost' identified via unix_socket;
This gives you passwordless mysql acces for a locally logged in root user. Btw. this is the default in recent ubuntu / debian releases.
some_user@box: mysql -u root # denied root@box: mysql # good some_user@box: sudo mysql # good, if "some_user" has sudo rights.
If you DO have a password set for MySQL, follow the instructions at Recover MySQL root Password, and then set your password to null:
For 5.7.6 and later
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass'
For 5.7.5 and earlier
update user set password=PASSWORD("") where User='root';
* needs a DB restart (see instructions at the link) for this to take effect.
sudo service mysql restart
IDENTIFIED VIA unix_socket statement is only for MariaDB.
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED VIA unix_socket;
For MySQL, the same is achieved by
IDENTIFIED WITH auth_socket.
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED WITH auth_socket;
Only a difference of two words, but they're really not the same.