Install MySql on Centos


Installing mysql can be a bit pain when there are problems in setting up remote access or changing passwords. But it can be easily managed if all the steps are done correctly
Installing Repo
Installing Mysql
yum –enablerepo=remi install mysql mysql-server mysql-devel php-mysql
Configuring Mysql
Set the MySQL service to start on boot
chkconfig –levels 235 mysqld on
Start the MySQL service
service mysqld start

Log into MySQL
mysql -u rootSet the root user password for all local domainsSET PASSWORD FOR ‘root’@'localhost’ = PASSWORD(‘new-password‘);SET PASSWORD FOR ‘root’@'localhost.localdomain’ = PASSWORD(‘new-password‘);SET PASSWORD FOR ‘root’@’127.0.0.1′ = PASSWORD(‘new-password‘);|
Setting up remote access to database
SET host FOR ‘root’@'localhost’ = ‘%’;
Drop the Any user
DROP USER ”@’localhost’;DROP USER ”@’localhost.localdomain’;
Exit MySQL
exit
alternative way is
mysql -u root
mysql> SET PASSWORD FOR 'ROOT'@'LOCALHOST"
> = PASSWORD('new_password');
Now while we’re still here, we’ll create a new HOST for root and allow root to login from anywhere.
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'
> IDENTIFIED BY 'password' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
mysql> exit