documentation/assets/js/76.585f5d41.js
2022-10-30 13:47:06 +00:00

1 line
11 KiB
JavaScript

(window.webpackJsonp=window.webpackJsonp||[]).push([[76],{420:function(a,e,s){"use strict";s.r(e);var t=s(48),r=Object(t.a)({},(function(){var a=this,e=a.$createElement,s=a._self._c||e;return s("ContentSlotsDistributor",{attrs:{"slot-key":a.$parent.slotKey}},[s("h1",{attrs:{id:"setting-up-mysql"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#setting-up-mysql"}},[a._v("#")]),a._v(" Setting up MySQL")]),a._v(" "),s("p"),s("div",{staticClass:"table-of-contents"},[s("ul",[s("li",[s("a",{attrs:{href:"#creating-a-database-for-pterodactyl"}},[a._v("Creating a database for Pterodactyl")]),s("ul",[s("li",[s("a",{attrs:{href:"#logging-in"}},[a._v("Logging In")])]),s("li",[s("a",{attrs:{href:"#creating-a-user"}},[a._v("Creating a user")])]),s("li",[s("a",{attrs:{href:"#create-a-database"}},[a._v("Create a database")])]),s("li",[s("a",{attrs:{href:"#assigning-permissions"}},[a._v("Assigning permissions")])])])]),s("li",[s("a",{attrs:{href:"#creating-a-database-host-for-nodes"}},[a._v("Creating a Database Host for Nodes")]),s("ul",[s("li",[s("a",{attrs:{href:"#creating-a-user"}},[a._v("Creating a user")])]),s("li",[s("a",{attrs:{href:"#assigning-permissions"}},[a._v("Assigning permissions")])]),s("li",[s("a",{attrs:{href:"#allowing-external-database-access"}},[a._v("Allowing external database access")])])])])])]),s("p"),a._v(" "),s("h2",{attrs:{id:"creating-a-database-for-pterodactyl"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#creating-a-database-for-pterodactyl"}},[a._v("#")]),a._v(" Creating a database for Pterodactyl")]),a._v(" "),s("p",[a._v("MySQL is a core component of Pterodactyl Panel but it can be confusing to setup and use if you've never done so before.\nThis is a very basic tutorial that skims just enough of the surface to set MySQL up and running with the panel.\nIf you're interested in learning more, there are some great tutorials available on the Internet.")]),a._v(" "),s("h3",{attrs:{id:"logging-in"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#logging-in"}},[a._v("#")]),a._v(" Logging In")]),a._v(" "),s("p",[a._v("The first step in this process is to login to the MySQL command line where we will be executing some statements to get\nthings setup. To do so, simply run the command below and provide the Root MySQL account's password that you setup when\ninstalling MySQL. If you do not remember doing this, chances are you can just hit enter as no password is set.")]),a._v(" "),s("div",{staticClass:"language-bash extra-class"},[s("pre",{pre:!0,attrs:{class:"language-bash"}},[s("code",[a._v("mysql -u root -p\n")])])]),s("h3",{attrs:{id:"creating-a-user"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#creating-a-user"}},[a._v("#")]),a._v(" Creating a user")]),a._v(" "),s("p",[a._v("For security sake, and due to changes in MySQL 5.7, you'll need to create a new user for the panel. To do so, we want\nto first tell MySQL to use the mysql database, which stores such information.")]),a._v(" "),s("p",[a._v("Next, we will create a user called "),s("code",[a._v("pterodactyl")]),a._v(" and allow logins from localhost which prevents any external connections\nto our database. You can also use "),s("code",[a._v("%")]),a._v(" as a wildcard or enter a numeric IP. We will also set the account password\nto "),s("code",[a._v("somePassword")]),a._v(".")]),a._v(" "),s("div",{staticClass:"language-sql extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sql"}},[s("code",[s("span",{pre:!0,attrs:{class:"token comment"}},[a._v("# Remember to change 'somePassword' below to be a unique password specific to this account.")]),a._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("CREATE")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("USER")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[a._v("'pterodactyl'")]),s("span",{pre:!0,attrs:{class:"token variable"}},[a._v("@'127.0.0.1'")]),a._v(" IDENTIFIED "),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("BY")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[a._v("'somePassword'")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n")])])]),s("h3",{attrs:{id:"create-a-database"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#create-a-database"}},[a._v("#")]),a._v(" Create a database")]),a._v(" "),s("p",[a._v("Next, we need to create a database for the panel. In this tutorial we will be naming the database "),s("code",[a._v("panel")]),a._v(", but you can\nsubstitute that for whatever name you wish.")]),a._v(" "),s("div",{staticClass:"language-sql extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sql"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("CREATE")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("DATABASE")]),a._v(" panel"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n")])])]),s("h3",{attrs:{id:"assigning-permissions"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#assigning-permissions"}},[a._v("#")]),a._v(" Assigning permissions")]),a._v(" "),s("p",[a._v("Finally, we need to tell MySQL that our pterodactyl user should have access to the panel database. To do this, simply\nrun the command below. If you plan on also using this MySQL instance as a database host on the Panel you'll want to\ninclude the "),s("code",[a._v("WITH GRANT OPTION")]),a._v(" (which we are doing here). If you won't be using this user as part of the host setup\nyou can remove that.")]),a._v(" "),s("div",{staticClass:"language-sql extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sql"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("GRANT")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("ALL")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("PRIVILEGES")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("ON")]),a._v(" panel"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(".")]),s("span",{pre:!0,attrs:{class:"token operator"}},[a._v("*")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("TO")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[a._v("'pterodactyl'")]),s("span",{pre:!0,attrs:{class:"token variable"}},[a._v("@'127.0.0.1'")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("WITH")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("GRANT")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("OPTION")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n")])])]),s("h2",{attrs:{id:"creating-a-database-host-for-nodes"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#creating-a-database-host-for-nodes"}},[a._v("#")]),a._v(" Creating a Database Host for Nodes")]),a._v(" "),s("div",{staticClass:"custom-block tip"},[s("p",{staticClass:"custom-block-title"},[a._v("TIP")]),a._v(" "),s("p",[a._v("This section covers creating a MySQL user that has permission to create and modify users. This allows the Panel to create per-server databases on the given host.")])]),a._v(" "),s("h3",{attrs:{id:"creating-a-user-2"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#creating-a-user-2"}},[a._v("#")]),a._v(" Creating a user")]),a._v(" "),s("p",[a._v("If your database is on a different host than the one where your Panel or Daemon is installed make sure to use the IP address of the machine the Panel is running on. If you use "),s("code",[a._v("127.0.0.1")]),a._v(" and try to connect externally, you will receive a connection refused error.")]),a._v(" "),s("div",{staticClass:"language-sql extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sql"}},[s("code",[s("span",{pre:!0,attrs:{class:"token comment"}},[a._v("# You should change the username and password below to something unique.")]),a._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("CREATE")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("USER")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[a._v("'pterodactyluser'")]),s("span",{pre:!0,attrs:{class:"token variable"}},[a._v("@'127.0.0.1'")]),a._v(" IDENTIFIED "),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("BY")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[a._v("'somepassword'")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n")])])]),s("h3",{attrs:{id:"assigning-permissions-2"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#assigning-permissions-2"}},[a._v("#")]),a._v(" Assigning permissions")]),a._v(" "),s("p",[a._v("The command below will give your newly created user the ability to create additional users, as well as create and destroy databases. As above, ensure "),s("code",[a._v("127.0.0.1")]),a._v(" matches the IP address you used in the previous command.")]),a._v(" "),s("div",{staticClass:"language-sql extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sql"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("GRANT")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("ALL")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("PRIVILEGES")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("ON")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[a._v("*")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(".")]),s("span",{pre:!0,attrs:{class:"token operator"}},[a._v("*")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("TO")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[a._v("'pterodactyluser'")]),s("span",{pre:!0,attrs:{class:"token variable"}},[a._v("@'127.0.0.1'")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("WITH")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("GRANT")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("OPTION")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n")])])]),s("h3",{attrs:{id:"allowing-external-database-access"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#allowing-external-database-access"}},[a._v("#")]),a._v(" Allowing external database access")]),a._v(" "),s("p",[a._v("Chances are you'll need to allow external access to this MySQL instance in order to allow servers to connect to it. To do this, open "),s("code",[a._v("my.cnf")]),a._v(", which varies in location depending on your OS and how MySQL was installed. You can type "),s("code",[a._v("find /etc -iname my.cnf")]),a._v(" to locate it.")]),a._v(" "),s("p",[a._v("Open "),s("code",[a._v("my.cnf")]),a._v(", add text below to the bottom of the file and save it:")]),a._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[a._v("[mysqld]\nbind-address=0.0.0.0\n")])])]),s("p",[a._v("Restart MySQL/MariaDB to apply these changes. This will override the default MySQL configuration, which by default will only accept requests from localhost. Updating this will allow connections on all interfaces, and thus, external connections. Make sure to allow the MySQL port (default 3306) in your firewall.")]),a._v(" "),s("p",[a._v("If your Database and Wings are on the same machine and won't need external access, you can also use the "),s("code",[a._v("docker0")]),a._v(" interface IP address rather than "),s("code",[a._v("127.0.0.1")]),a._v(". This IP address can be found by running "),s("code",[a._v("ip addr | grep docker0")]),a._v(", and it likely looks like "),s("code",[a._v("172.x.x.x")]),a._v(".")])])}),[],!1,null,null,null);e.default=r.exports}}]);