注意:

The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.

Difference between revisions of "Package:MySQL"

From Funtoo
Jump to navigation Jump to search
(initial commit)
 
 
(9 intermediate revisions by 2 users not shown)
Line 5: Line 5:
|Homepage=http://www.mysql.com/
|Homepage=http://www.mysql.com/
}}
}}
MySQL is the M in the lamp/lemp/llmp stack.
{{PageNeedsUpdates}}
MySQL is the M in the lamp/lemp/llmp stack. It is a popular, & common database that accepts SQL statements.  {{package|dev-db/mariadb}} & {{package|dev-db/percona-server}} are drop in replacements for MySQL.
 
=== Installation ===
 
{{console|body=###i## emerge mysql}}
 
==== First Run ====
MySQL requires configuration upon instillation.
 
To deploy MySQL:
{{console|body=###i## emerge --config dev-db/mysql}}
 
==== Init ====
To start mysql:
{{console|body=###i## rc-service mysql start}}
 
To start upon boot:
{{console|body=###i## rc-update add mysql default}}
 
=== Usage ===
To use mysql you will need to run MySQL as the funtoo root user, logging in as the mysql database root user.  The system root user is not the same as the database root user, and passwords for both should be different.
{{console|body=###i## mysql -u root -p
Enter password:
mysql>
}}
mysql is now blinking at you ready for SQL statements.
 
Root use is discouraged, for every database you require, create a user, and a database specific for the application, then allow the user access with as stripped down as possible permissions.  We will use phpBB examples of creating a phpBB user & database.
 
{{console|body=###i## mysql -u root -p
Enter password:
mysql> ##i##CREATE USER 'phpbb'@'localhost' IDENTIFIED BY 'changeme';
mysql> ##i##CREATE DATABASE IF NOT EXISTS `phpbb` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
mysql> ##i##GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `phpbb`.* TO 'phpbb'@'localhost' IDENTIFIED BY 'changeme';
mysql> ##i##\q
}}
 
=== Secure ===
==== Lockdown ====
MySQL is by default insecure.
 
to lock down your MySQL install:
{{console|body=###i## mysql_secure_installation}}
==== Logging ====
 
By default MySQL logs every action, including leaving plain text passwords in its history file.
 
To remove the history file:
{{console|body=###i## rm /root/.mysql_history}}
 
To automatically remove future history:
{{console|body=###i## ln -s /dev/null /root/.mysql_history}}
 
=== ZFS ===
If you are a zfs add the following to the mysql configuration file (/etc/mysql/my.cnf).
{{console|body=###i## echo "innodb_use_native_aio = 0" >> /etc/mysql/my.cnf}}
 
=== Media ===
==== Programming ====
{{#widget:YouTube|id=yPu6qV5byu4}}
 
{{EbuildFooter}}
{{EbuildFooter}}

Latest revision as of 04:50, April 10, 2015

MySQL

   Tip

We welcome improvements to this page. To edit this page, Create a Funtoo account. Then log in and then click here to edit this page. See our editing guidelines to becoming a wiki-editing pro.

MySQL is the M in the lamp/lemp/llmp stack. It is a popular, & common database that accepts SQL statements. dev-db/mariadb & No results are drop in replacements for MySQL.

Installation

root # emerge mysql

First Run

MySQL requires configuration upon instillation.

To deploy MySQL:

root # emerge --config dev-db/mysql

Init

To start mysql:

root # rc-service mysql start

To start upon boot:

root # rc-update add mysql default

Usage

To use mysql you will need to run MySQL as the funtoo root user, logging in as the mysql database root user. The system root user is not the same as the database root user, and passwords for both should be different.

root # mysql -u root -p
Enter password: 
mysql>

mysql is now blinking at you ready for SQL statements.

Root use is discouraged, for every database you require, create a user, and a database specific for the application, then allow the user access with as stripped down as possible permissions. We will use phpBB examples of creating a phpBB user & database.

root # mysql -u root -p
Enter password: 
mysql> CREATE USER 'phpbb'@'localhost' IDENTIFIED BY 'changeme';
mysql> CREATE DATABASE IF NOT EXISTS `phpbb` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `phpbb`.* TO 'phpbb'@'localhost' IDENTIFIED BY 'changeme';
mysql> \q

Secure

Lockdown

MySQL is by default insecure.

to lock down your MySQL install:

root # mysql_secure_installation

Logging

By default MySQL logs every action, including leaving plain text passwords in its history file.

To remove the history file:

root # rm /root/.mysql_history

To automatically remove future history:

root # ln -s /dev/null /root/.mysql_history

ZFS

If you are a zfs add the following to the mysql configuration file (/etc/mysql/my.cnf).

root # echo "innodb_use_native_aio = 0" >> /etc/mysql/my.cnf

Media

Programming