Perhaps you provided the wrong password? Don't worry, you can reset Ubuntu mysql root password, here's how to do it:
If mysql is running, then you have to stop it first. If you not sure, we can check Ubuntu running services with ps command to check mysql service is there or not.
If you see mysql service like in the example above, then you need to stop it. All you need from the ps command above is the process id. Look closely at mysql service, and write down that number. Then you can issue the command below:
We can use the same ps command as before to check that mysql really died. So there is no more mysql service.
There are two ways to reset mysql root password. The first way is by putting a script of mysql command to reset root password in a file. Then run mysqld_safe command with the file.
The second way is by running mysql directly from the shell.
Here is a step by step example of resetting mysql root password with a file:
1) Create a text file in your home directory named mysql-passwd with the content below:
2) Now you can start mysql with the mysql password file to reset Ubuntu mysql root password. Follow the syntax below but change the password name to yours.
3)After the mysql server successfully started, delete the root password file you in your home directory.
4)You can now login mysql using your new password.
If mysql is running, then you have to stop it first. If you not sure, we can check Ubuntu running services with ps command to check mysql service is there or not.
luzar@ubuntu:~$ ps aux | grep mysqld
root 4078 0.0 0.1 1772 524 ? S 05:19 0:00 /bin/sh /usr/bin/mysqld_safe
mysql 4120 0.0 3.1 127088 16312 ? Sl 05:19 0:02 /usr/sbin/mysqld --basedir
root 4122 0.0 0.1 1700 556 ? S 05:19 0:00 logger -p daemon.err -t
luzar 4885 0.0 0.1 3004 752 pts/0 R+ 09:50 0:00 grep mysqld
If you see mysql service like in the example above, then you need to stop it. All you need from the ps command above is the process id. Look closely at mysql service, and write down that number. Then you can issue the command below:
luzar@ubuntu:~$ sudo kill 4120
luzar@ubuntu:~$ ps aux | grep mysqld
luzar 4891 0.0 0.1 3004 752 pts/0 R+ 09:50 0:00 grep mysqld
luzar@ubuntu:~$
We can use the same ps command as before to check that mysql really died. So there is no more mysql service.
There are two ways to reset mysql root password. The first way is by putting a script of mysql command to reset root password in a file. Then run mysqld_safe command with the file.
The second way is by running mysql directly from the shell.
Here is a step by step example of resetting mysql root password with a file:
1) Create a text file in your home directory named mysql-passwd with the content below:
UPDATE mysql.user SET Password=PASSWORD('Password') WHERE User='root'; FLUSH PRIVILEGES;
2) Now you can start mysql with the mysql password file to reset Ubuntu mysql root password. Follow the syntax below but change the password name to yours.
luzar@ubuntu:~$ mysqld_safe --init-file=/home/me/mysql-passwd &
3)After the mysql server successfully started, delete the root password file you in your home directory.
4)You can now login mysql using your new password.
0 comments:
Post a Comment