Thursday, August 30, 2012

Install MySQL and reset root password

Install MySQL 

Using yum to install MySQL on CentOS is very easy:
yum install mysql mysql-server mysql-devel
To use mysql with PHP, you should install :
yum install php-mysql
Make mysql as a service and start when you boot your system:
# chkconfig mysqld on
# service mysqld start

To reset your root password
1. Stop mysql using command:
# sudo service mysqld stop
2. Start up the mysql daemon and skip the grant tables which store the passwords.
# mysql safe --skip-grant-tables
3. Connect to mysql without a password
# mysql --user=root mysql
4. Reset root password
# update user set Password=PASSWORD('new_password') where user='root';
# flush privileges;
# exit;
Now you can login mysql using password.

No comments:

Post a Comment