Difference between revisions of "MySQL"

From MineOS
Jump to: navigation, search
(Auto-starting mysqld on boot)
 
(35 intermediate revisions by one user not shown)
Line 1: Line 1:
== Dependencies ==
+
{{Buildfromscratch}}
=== Ports ===
+
MySQL installation ''through the ports system'' requires cmake and libaio to be installed first, or else installing MySQL will not complete. libaio requires cmake as well, so  be sure to install cmake first.
+
  
<nowiki>
+
== Youtube walk-through ==
# cd /usr/ports/opt/cmake
+
[http://www.youtube.com/watch?v=Fcr7N3f7IxY Securing MySQL and installing phpMyAdmin]
# pkgmk -d -i
+
</nowiki>
+
  
<nowiki>
+
== Securing MySQL ==
# cd /usr/ports/opt/libaio
+
The MySQL password is not set by default (blank), and can only be set when the MySQL daemon is running (upon first boot). To set the password, execute the following command:
# pkgmk -d -i
+
</nowiki>
+
  
=== User ===
+
{{executeasroot
MySQL requires the mysql user and group to exist prior to successful installation. Create them before insattling mysql via ports.
+
| commands = mysql_secure_installation}}
  
<nowiki>
+
== Disabling MySQL ==
# groupadd mysql
+
If you are certain you have no need for MySQL, either for websites or for your Minecraft server mods, you may remove it from the services list.
# useradd -g mysql -M -s /sbin/nologin mysql
+
</nowiki>
+
  
== Installing from ports ==
+
{{executeasroot
<nowiki>
+
| commands = vi /etc/rc.conf}}
# cd /usr/ports/opt/mysql
+
# pkgmk -d -i
+
# mysql_install_db --user=mysql
+
</nowiki>
+
  
== Auto-starting mysqld on boot ==
+
[[File:mysqld_rc.png|thumb|none|400px|Remove mysqld from the list]]
# Edit the startup services config file: <tt>vi /etc/rc.conf</tt>
+
# Append <tt>lighttpd</tt> at the end of the start-up services list.
+
# Save and quit with <tt>:wq</tt>
+
# <tt>reboot</tt> and confirm <tt>mysqld</tt> in running processes.
+
  
[[File:mysqld_rc.png|thumb|none|400px|Adjusted /etc/rc.conf]]
+
== PhpMyAdmin ==
 +
[[PhpMyAdmin]] is available as an addon. To install, ensure you have first secured MySQL. Then, follow the steps to download and install [[PhpMyAdmin]] from its wiki page.
 +
 
 +
== Enabling remote access/TCP-IP connectivity ==
 +
 
 +
Remote access/TCP-IP connectivity is disabled by default ''on installs <= 0.4.6''--later versions can ignore this step as it has already been automated.  All these actions must be done as '''root''':
 +
 
 +
Edit the <tt>/etc/my.cnf</tt> file and comment out the line:
 +
 
 +
<syntaxhighlight lang="bash">
 +
#skip-networking
 +
</syntaxhighlight>
 +
 
 +
Edit the hosts.allow file as well to add the mysqld daemon:
 +
 
 +
<syntaxhighlight lang="bash">
 +
mysqld: ALL
 +
SSHD: ALL
 +
</syntaxhighlight>
 +
 
 +
Have all localhost generated packets accepted by default in [[iptables]]:
 +
 
 +
{{executeasroot
 +
| commands = iptables -A INPUT -i lo -j ACCEPT
 +
iptables-save > /etc/iptables-rules}}
 +
 
 +
You will need to restart the mysqld daemon for these changes to take effect.
 +
 
 +
{{executeasroot
 +
| commands = /etc/rc.d/mysqld restart}}
 +
 
 +
[[Category:Maintenance]]
 +
[[Category:Securing]]
 +
[[Category:Addons]]
 +
[[Category:Connectivity]]

Latest revision as of 10:45, 2 October 2017

Contents

Youtube walk-through

Securing MySQL and installing phpMyAdmin

Securing MySQL

The MySQL password is not set by default (blank), and can only be set when the MySQL daemon is running (upon first boot). To set the password, execute the following command:

Disabling MySQL

If you are certain you have no need for MySQL, either for websites or for your Minecraft server mods, you may remove it from the services list.

Remove mysqld from the list

PhpMyAdmin

PhpMyAdmin is available as an addon. To install, ensure you have first secured MySQL. Then, follow the steps to download and install PhpMyAdmin from its wiki page.

Enabling remote access/TCP-IP connectivity

Remote access/TCP-IP connectivity is disabled by default on installs <= 0.4.6--later versions can ignore this step as it has already been automated. All these actions must be done as root:

Edit the /etc/my.cnf file and comment out the line:

#skip-networking

Edit the hosts.allow file as well to add the mysqld daemon:

mysqld: ALL
SSHD: ALL

Have all localhost generated packets accepted by default in iptables:

You will need to restart the mysqld daemon for these changes to take effect.