From Gentoo Wiki
Jump to: navigation, search
This page contains changes which are not marked for translation.

Other languages:
Deutsch • ‎English • ‎日本語 • ‎한국어 • ‎русский

MySQL is a popular, free software relational database management system. It is often used in conjunction with web applications (such as many PHP sites), but has gained many more enterprise-level features since its start in 1994. An alternative fork is MariaDB.


USE flags

Before installing dev-db/mysql, carefully consider the USE flags that influence the package deployment and features. The following table gives an overview of the package' supported USE flags:

USE flags for dev-db/mysql A fast, multi-threaded, multi-user SQL database server

debug Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see global
embedded Build embedded server (libmysqld) local
extraengine Add support for alternative storage engines (Archive, CSV, Blackhole, Federated(X), Partition) local
jemalloc Use dev-libs/jemalloc for allocations. local
latin1 Use LATIN1 encoding instead of UTF8 local
libressl Enable SSL connections and crypto functions using dev-libs/libressl local
numa Enable NUMA support using sys-process/numactl (NUMA kernel support is also required) local
openssl Enable SSL connections and crypto functions using dev-libs/openssl local
perl Add optional support/bindings for the Perl language global
profiling Add support for statement profiling (requires USE=community). local
selinux !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur global
server Build the server program local
static !!do not set this during bootstrap!! Causes binaries to be statically linked instead of dynamically global
static-libs Build static versions of dynamic libraries as well global
systemtap Build support for profiling and tracing using dev-util/systemtap local
tcmalloc Use the dev-util/google-perftools libraries to replace the malloc() implementation with a possibly faster one global
test Install upstream testsuites for end use. local
yassl Enable SSL connections and crypto functions using the bundled yaSSL local


Once the proper USE flags have been set, install mysql:

root #emerge --ask dev-db/mysql




To have the database(s) started automatically at boot, add the mysql init script to the default runlevel:

root #rc-update add mysql default

After configuring the database, which is mentioned later in this document, start the mysql service:

root #rc-service mysql start

Preliminary configuration

The dev-db/mysql package handles the preliminary setup of MySQL through the --config option:

root #emerge --config dev-db/mysql

This will create a database, set proper permissions on it and assist in creating a good root password (this is for the MySQL root account, which is not related to the Linux root account).

To purge anonymous users and test databases from the installation, run mysql_secure_installation after the preliminary setup:

root #mysql_secure_installation

In-database configuration

When the database is up and running, connect to it using the mysql client application.

user $mysql -u root -p -h localhost
Enter root password: 
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.5.1
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

From this point, a session to the MySQL instance is open, allowing for queries and administrative commands to be serviced.

Erasing command history

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

Alternatively you can permanently disable history logging with the following:

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

See also

External resources