Table of Contents
Install MySQL On Slackware
Install MySQL from the official Slackware discs or using slackpkg. If you performed a full install of Slackware, then you already have MySQL on your computer.
- Create the needed database(s) and set their permissions properly
As root, run:
root@darkstar# mysql_install_db --user=mysql
The user specified by
–userwill own the database files, so it's important to set the right user here, otherwise MySQL won't be able to write to your databases. By default MySQL in Slackware runs as user “mysql”, so that is the safe choice.
- Enable execution of the rc script to start MySQL automatically on boot
This is optional.
root@darkstar# chmod 755 /etc/rc.d/rc.mysqld
- Enable networking if needed
Networking is disabled by default to improve security. If you want to allow network connections, comment out this line in
- Start mysqld
root@darkstar# /etc/rc.d/rc.mysqld start
and proceed to the next section “Securing MySQL”.
Automatic configuration of secure access
- Run the following command, and answer the questions
The initial root password is “” (the empty string), so just hit ENTER when the above command asks for the password
Manual configuration of secure access
- Set a password for MySQL's root account
root@darkstar# mysqladmin -u root password 'new-password-here'
If you enabled networking, you should also run this command:
root@darkstar# mysqladmin -u root -h 'your-hostname' password 'new-password'
mysql_install_dbresults, these commands are printed, you can copy/paste them. The hostname will already be replaced by yours.
Connecting to your MySQL server
- Connect to your MySQL server using the following command
user@darkstar$ mysql -u root -p
- For security reasons you should delete the anonymous user
- For the localhost server:
mysql> use mysql mysql> SELECT user, host FROM user; mysql> DELETE FROM user WHERE host='localhost' AND user='';
- If you enabled networking, you should run this command instead:
mysql> use mysql mysql> SELECT user, host FROM user; mysql> DELETE FROM user WHERE user='';
Adding Unicode support
- Change directory to the
/etc/directory, and select the configuration which you prefer. For a “simple” database service without heavy MySQL load, it is recommended to use “
my-large.cnf” if you have 2 GB of RAM or more. Copy the configuration file you chose and name the copy
/etc/my.cnfadding these lines in the section “
[mysqld] collation-server = utf8_unicode_ci init-connect='SET NAMES utf8' character-set-server = utf8
This gives you full UTF8 support in your MySQL server, after you restarted it.
More on Unicode / UTF8 character set support is described here: http://stackoverflow.com/questions/3513773/change-mysql-default-character-set-to-utf8-in-my-cnf
- Server start errors can be seen in the error log that is located by default at
/var/lib/mysql/<hostname>.err. Another option is to run the server directly and direct the output to the console (use Ctrl+\ to stop the server). Run:
root@darkstar# /usr/bin/mysqld_safe --console
- Resetting the root password can be done by creating a new cnf file and add the following lines (please change the password in this example):
UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE USER='root'; FLUSH PRIVILEGES;
Save this file (any name would do) and start the server with the –init-file argument:
root@darkstar# /usr/bin/mysqld_safe --defaults-file="new_cnf_file.cnf"
- Originally written by arfon