Skip to content

Commit e98e493

Browse files
committed
allow acces to database from host with Vagrant
1 parent 796748c commit e98e493

File tree

4 files changed

+205
-4
lines changed

4 files changed

+205
-4
lines changed

.dev/vagrant/mariadb.cnf

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
# MariaDB database server configuration file.
2+
#
3+
# You can copy this file to one of:
4+
# - "/etc/mysql/my.cnf" to set global options,
5+
# - "~/.my.cnf" to set user-specific options.
6+
#
7+
# One can use all long options that the program supports.
8+
# Run program with --help to get a list of available options and with
9+
# --print-defaults to see which it would actually understand and use.
10+
#
11+
# For explanations see
12+
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
13+
14+
# This will be passed to all mysql clients
15+
# It has been reported that passwords should be enclosed with ticks/quotes
16+
# escpecially if they contain "#" chars...
17+
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
18+
[client]
19+
port = 3306
20+
socket = /var/run/mysqld/mysqld.sock
21+
22+
# Here is entries for some specific programs
23+
# The following values assume you have at least 32M ram
24+
25+
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
26+
[mysqld_safe]
27+
socket = /var/run/mysqld/mysqld.sock
28+
nice = 0
29+
30+
[mysqld]
31+
#
32+
# * Basic Settings
33+
#
34+
user = mysql
35+
pid-file = /var/run/mysqld/mysqld.pid
36+
socket = /var/run/mysqld/mysqld.sock
37+
port = 3306
38+
basedir = /usr
39+
datadir = /var/lib/mysql
40+
tmpdir = /tmp
41+
lc_messages_dir = /usr/share/mysql
42+
lc_messages = en_US
43+
skip-external-locking
44+
#
45+
# Instead of skip-networking the default is now to listen only on
46+
# localhost which is more compatible and is not less secure.
47+
bind-address = 0.0.0.0
48+
#
49+
# * Fine Tuning
50+
#
51+
max_connections = 100
52+
connect_timeout = 5
53+
wait_timeout = 600
54+
max_allowed_packet = 16M
55+
thread_cache_size = 128
56+
sort_buffer_size = 4M
57+
bulk_insert_buffer_size = 16M
58+
tmp_table_size = 32M
59+
max_heap_table_size = 32M
60+
#
61+
# * MyISAM
62+
#
63+
# This replaces the startup script and checks MyISAM tables if needed
64+
# the first time they are touched. On error, make copy and try a repair.
65+
myisam_recover_options = BACKUP
66+
key_buffer_size = 128M
67+
#open-files-limit = 2000
68+
table_open_cache = 400
69+
myisam_sort_buffer_size = 512M
70+
concurrent_insert = 2
71+
read_buffer_size = 2M
72+
read_rnd_buffer_size = 1M
73+
#
74+
# * Query Cache Configuration
75+
#
76+
# Cache only tiny result sets, so we can fit more in the query cache.
77+
query_cache_limit = 128K
78+
query_cache_size = 64M
79+
# for more write intensive setups, set to DEMAND or OFF
80+
#query_cache_type = DEMAND
81+
#
82+
# * Logging and Replication
83+
#
84+
# Both location gets rotated by the cronjob.
85+
# Be aware that this log type is a performance killer.
86+
# As of 5.1 you can enable the log at runtime!
87+
#general_log_file = /var/log/mysql/mysql.log
88+
#general_log = 1
89+
#
90+
# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
91+
#
92+
# we do want to know about network errors and such
93+
log_warnings = 2
94+
#
95+
# Enable the slow query log to see queries with especially long duration
96+
#slow_query_log[={0|1}]
97+
slow_query_log_file = /var/log/mysql/mariadb-slow.log
98+
long_query_time = 10
99+
#log_slow_rate_limit = 1000
100+
log_slow_verbosity = query_plan
101+
102+
#log-queries-not-using-indexes
103+
#log_slow_admin_statements
104+
#
105+
# The following can be used as easy to replay backup logs or for replication.
106+
# note: if you are setting up a replication slave, see README.Debian about
107+
# other settings you may need to change.
108+
#server-id = 1
109+
#report_host = master1
110+
#auto_increment_increment = 2
111+
#auto_increment_offset = 1
112+
log_bin = /var/log/mysql/mariadb-bin
113+
log_bin_index = /var/log/mysql/mariadb-bin.index
114+
# not fab for performance, but safer
115+
#sync_binlog = 1
116+
expire_logs_days = 10
117+
max_binlog_size = 100M
118+
# slaves
119+
#relay_log = /var/log/mysql/relay-bin
120+
#relay_log_index = /var/log/mysql/relay-bin.index
121+
#relay_log_info_file = /var/log/mysql/relay-bin.info
122+
#log_slave_updates
123+
#read_only
124+
#
125+
# If applications support it, this stricter sql_mode prevents some
126+
# mistakes like inserting invalid dates etc.
127+
#sql_mode = NO_ENGINE_SUBSTITUTION,TRADITIONAL
128+
#
129+
# * InnoDB
130+
#
131+
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
132+
# Read the manual for more InnoDB related options. There are many!
133+
default_storage_engine = InnoDB
134+
# you can't just change log file size, requires special procedure
135+
#innodb_log_file_size = 50M
136+
innodb_buffer_pool_size = 256M
137+
innodb_log_buffer_size = 8M
138+
innodb_file_per_table = 1
139+
innodb_open_files = 400
140+
innodb_io_capacity = 400
141+
innodb_flush_method = O_DIRECT
142+
#
143+
# * Security Features
144+
#
145+
# Read the manual, too, if you want chroot!
146+
# chroot = /var/lib/mysql/
147+
#
148+
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
149+
#
150+
# ssl-ca=/etc/mysql/cacert.pem
151+
# ssl-cert=/etc/mysql/server-cert.pem
152+
# ssl-key=/etc/mysql/server-key.pem
153+
154+
#
155+
# * Galera-related settings
156+
#
157+
[galera]
158+
# Mandatory settings
159+
#wsrep_on=ON
160+
#wsrep_provider=
161+
#wsrep_cluster_address=
162+
#binlog_format=row
163+
#default_storage_engine=InnoDB
164+
#innodb_autoinc_lock_mode=2
165+
#
166+
# Allow server to accept connections on all interfaces.
167+
#
168+
#bind-address=0.0.0.0
169+
#
170+
# Optional setting
171+
#wsrep_slave_threads=1
172+
#innodb_flush_log_at_trx_commit=0
173+
174+
[mysqldump]
175+
quick
176+
quote-names
177+
max_allowed_packet = 16M
178+
179+
[mysql]
180+
#no-auto-rehash # faster start of mysql but no tab completion
181+
182+
[isamchk]
183+
key_buffer = 16M
184+
185+
#
186+
# * IMPORTANT: Additional settings that can override those from this file!
187+
# The files must end with '.cnf', otherwise they'll be ignored.
188+
#
189+
!includedir /etc/mysql/conf.d/

.dev/vagrant/motd.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@
33

44
Install: /var/www/html/pterodactyl
55
Ports:
6-
Panel: 80 (50080 on host)
6+
Panel: 80 (50080 on host)
77
MailHog: 8025 (58025 on host)
8-
MySQL: 3306
8+
MySQL: 3306 (53306 on host)
9+
10+
Default panel users:
11+
user: admin passwd: Ptero123 (admin user)
12+
user: user passwd: Ptero123 (standard user)
13+
14+
MySQL is accessible using root/pterodactyl or pterodactyl/pterodactyl
915

1016
Services for pteroq and mailhog are running
1117
#####################################################

.dev/vagrant/provision.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
echo "Provisioning development environment for Pterodactyl Panel."
44
cp /var/www/html/pterodactyl/.dev/vagrant/motd.txt /etc/motd
5+
chmod -x /etc/update-motd.d/10-help-text /etc/update-motd.d/51-cloudguest
56

67
apt-get install -y software-properties-common > /dev/null
78

@@ -37,10 +38,13 @@ ln -s /etc/nginx/sites-available/pterodactyl.conf /etc/nginx/sites-enabled/ptero
3738
service nginx restart
3839

3940
echo "Setup database"
41+
# Replace default config with custom one to bind mysql to 0.0.0.0 to make it accessible from the host
42+
cp /var/www/html/pterodactyl/.dev/vagrant/mariadb.cnf /etc/mysql/my.cnf
43+
systemctl restart mariadb
4044
mysql -u root -ppterodactyl << SQL
41-
CREATE USER 'pterodactyl'@'localhost' IDENTIFIED BY 'pterodactyl';
4245
CREATE DATABASE panel;
43-
GRANT ALL PRIVILEGES ON panel.* TO 'pterodactyl'@'localhost';
46+
GRANT ALL PRIVILEGES ON panel.* TO 'pterodactyl'@'%' IDENTIFIED BY 'pterodactyl' WITH GRANT OPTION;
47+
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'pterodactyl' WITH GRANT OPTION;
4448
FLUSH PRIVILEGES;
4549
SQL
4650

@@ -70,3 +74,4 @@ echo "The panel should be available at http://localhost:50080/"
7074
echo "You may use the default admin user to login: admin/Ptero123"
7175
echo "A normal user has also been created: user/Ptero123"
7276
echo "MailHog is available at http://localhost:58025/"
77+
echo "Connect to the database using root/pterodactyl or pterodactyl/pterodactyl on localhost:53306"

Vagrantfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ Vagrant.configure("2") do |config|
1313
config.vm.network :private_network, ip: "192.168.50.2"
1414
config.vm.network :forwarded_port, guest: 80, host: 50080
1515
config.vm.network :forwarded_port, guest: 8025, host: 58025
16+
config.vm.network :forwarded_port, guest: 3306, host: 53306
1617

1718
end

0 commit comments

Comments
 (0)