layout | group | subgroup | title | menu_title | menu_order | version | github_link |
---|---|---|---|---|---|---|---|
default |
install_pre |
Prerequisites |
Set up a remote MySQL database connection |
Set up a remote MySQL database connection |
175 |
2.0 |
install-gde/prereq/mysql_remote.md |
This is an advanced topic that should be used only by an experienced network administrator or database administrator. You must have root
access to the file system and you must be able to log in to MySQL as root
.
Before you begin, you must:
- Install MySQL server on the database server
- Create a database instance on the database server
- Install the MySQL client on your Magento web node. Consult MySQL documentation for details.
Use the following guidelines to configure remote database connections if your web server or database server are clustered:
-
You must configure a connection for each web server node
-
Typically, you configure a database connection to the database load balancer; however, database clustering can be complex and configuring it is up to you. Magento makes no specific recommendations for database clustering.
For more information, see MySQL documentation.
If you have issues connecting to either host, first ping the other host to make sure it's reachable. You also might need to allow connections from one host to another by modifying firewall and SELinux rules (if you use SELinux).
To create a remote connection:-
On your database server, as a user with
root
privileges, open your MySQL configuration file.To locate it, enter the following command:
mysql --help
The location displays similar to the following:
Default options are read from the following files in the given order: /etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf
-
Search the configuration file for
bind-address
.If it exists, change the value as follows.
If it doesn't exist, add it anywhere except the
[mysqld]
section.bind-address = <ip address of your Magento web node>
See MySQL documentation, especially if you have a clustered web server.
-
Save your changes to the configuration file and exit the text editor.
-
Restart the MySQL service:
CentOS:
service mysqld restart
Ubuntu:
service mysql restart
If MySQL fails to start, look in syslog for the source of the issue. Resolve the issue using MySQL documentation or another authoritative source.
This example grants the root
database user full access to the database on the remote host.
To grant access to a database user:
-
Log in to the database server.
-
Connect to the MySQL database as the
root
user. -
Enter the following command:
GRANT ALL ON <local database name>.* TO <remote web node user name>@<remote web node server ip address> IDENTIFIED BY '<database user password>';
For example,
GRANT ALL ON magento_remote.* TO dbuser@192.0.2.50 IDENTIFIED BY 'dbuserpassword';
If your web server is clustered, enter the same command on every web server. You must use the same user name for every web server.
mysql -u <local database user name> -h <database server ip address> -p
If the MySQL monitor displays as follows, the database is ready for the Magento software:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 213
Server version: 5.6.26 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
If your web server is clustered, enter the command on each web server host.
When you install the Magento software using either the command line or Setup Wizard, you must specify the following:- The Base URL (also referred to as the store address) specifies the host name or IP address of the web node
- Database host is the remote database server IP address (or load balancer if the database server is clustered)
- Database user name is the local web node database user to which you gave access
- Database password is the local web node user's password
- Database name is the name of the database on the remote server
- Installing optional software
- Apache
- PHP 5.5, 5.6, or 7.0—Ubuntu
- PHP 5.5, 5.6, or 7.0—CentOS
- Configuring security options
- [How to get the Magento software]({{ page.baseurl }}install-gde/bk-install-guide.html)