Author |
Topic: Install and configure MySQL on AWS EC2 instance |
|
Linux member offline |
|
posts: |
120 |
joined: |
01/24/2011 |
from: |
San Jose, CA |
|
|
|
|
|
Install and configure MySQL on AWS EC2 instance |
Here’s how to do that:
$ sudo yum list | grep mysql*
$ sudo yum install mysql
$ sudo yum install mysql-server
$ sudo yum install mysql-devel
$ sudo chgrp -R mysql /var/lib/mysql
$ chmod -R 770 /var/lib/mysql
$ sudo service mysqld start
Now you’ll have MySQL installed and the service has started. The next step is to set a password for the root user:
$ usr/bin/mysqladmin -u root password secret
If you only want to use MySQL internally, then you’re all done now.
But if you access MySQL externally then you’ll get the error message similar like this:
SQL Error (1130): Host 'adsl-71-146-123-45.sbcglobal.net' is not allowed to connect to this MySQL server
|
|
|
|
|
|
|
Linux member offline |
|
posts: |
120 |
joined: |
01/24/2011 |
from: |
San Jose, CA |
|
|
|
|
|
How to enable remote access to MySQL? |
Connect to mysql server:
$ mysql -u root -p secret
Create a new database called foo
mysql> CREATE DATABASE foo;
If you want database foo to be accessed by user bar from remote ipAddress 12.34.56.78, then you need to type the following command
mysql> GRANT ALL ON foo.* TO bar@'12.34.56.78' IDENTIFIED BY 'secret';
|
|
|
|
|
|
|
Linux member offline |
|
posts: |
120 |
joined: |
01/24/2011 |
from: |
San Jose, CA |
|
|
|
|
|
Grant and revoke remote root access to MySQL |
To grant root access from all hosts (except for localhost):
mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY 'secret';
To revoke root access from all hosts (except for localhost):
mysql> DELETE FROM mysql.user WHERE User = 'root' AND Host = '%';
mysql> FLUSH PRIVILEGES;
|
|
|
|
|
|
|
Linux member offline |
|
posts: |
120 |
joined: |
01/24/2011 |
from: |
San Jose, CA |
|
|
|
|
|
MySQL client |
The testing client is Heidi SQL, which is working. |
|
|
|
|
|
|