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
Advertisements
Categories: Linux, MySQL, Tips and Tricks
  1. No comments yet.
  1. No trackbacks yet.

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

%d bloggers like this: