Saturday, May 25, 2013

Mysql server installation on CentOS/RHEL

Quick installation to website hosting:

1. Install mysql server package:

# yum install mysql-server

2. Enable mysql server on system boot and startup this service now:
# chkconfig mysqld on
# service mysqld start

3. Setup myql root's password:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h hostname.domain.com password 'new-password'

4. Test if you can connect using new password:
$ mysql -u root -p
Enter password:
...
mysql>

Create new database:
mysql> CREATE DATABASE database_name;
Query OK, 1 row affected (0,01 sec)

Setup user account and grant him access to this database:
mysql> CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'localhost'
    -> WITH GRANT OPTION;

No comments:

Post a Comment