Home > Linux, MySQL, Tips and Tricks > MySQL root login without password

MySQL root login without password

You must be on localhost and have Linux root permissions

I had to create a MySQL account for myself on a Linux box. So here it is

# kill the running mysql process
sudo service mysql stop

# start mysql in safe mode and skip grant tables 
sudo mysqld_safe --skip-grant-tables --skip-networking &

# log in with root 
mysql -u root 

# ( optional ) flush privileges, create new user, grant privileges 
FLUSH PRIVILEGES;
CREATE USER 'new-user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'new-user'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit;

# stop mysqld_safe process 
ps -A | grep mysql
sudo kill < mysql-pid-here >

# start mysql normally 
sudo service mysql start
Categories: Linux, MySQL, Tips and Tricks Tags:
  1. No comments yet.
  1. No trackbacks yet.