This is an old revision of the document!
Table of Contents
Install MySQL On Slackware
Install MySQL
Install MySQL from the official Slackware discs or using slackpkg.
Configure MySQL
1) Create the needed database(s) and set their permissions properly
As root, run:
root@darkstar# mysql_install_db --user=mysql
User specified by –user
will own database files, so it's important to
set right user here, otherwise MySQL won't be able to write to database. By
default MySQL in Slackware runs as user “mysql”, so it's the safe choice.
2) Enable execution of rc script to start MySQL automatically on boot
This is optional.
root@darkstar# chmod 755 /etc/rc.d/rc.mysqld
3) Enable networking if needed
Networking is disabled by default to improve security. If you want to allow
network connections, comment out this line in /etc/rc.d/rc.mysqld
- rc.mysqld
#SKIP="--skip-networking"
4) Start mysqld
root@darkstar# /etc/rc.d/rc.mysqld start
AUTOMATIC
5) 6) 7) Run the following, answer the questions
root@darkstar# /usr/bin/mysql_secure_installation
Initial root password is “” so, just hit ENTER
MANUAL
5) Set a password for MySQL's root password
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_db
results, these commands are printed, you can
copy/paste them. The hostname will already be replaced by yours.
6) Connect to your MySQL server
user@darkstar$ mysql -u root -p
7) 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='';
Finish set configfile
- Go to
/etc/mysql
folder, and choose config, who you prefer ( for simple variants without heavy mysql load,if you have 2+ Gb RAM, i recommend my-large.cnf) and copy it to \ as/etc/my.cnf
. - Edit
/etc/my.cnf
adding these lines after [mysqld]:
[mysqld] collation-server = utf8_unicode_ci init-connect='SET NAMES utf8' character-set-server = utf8
This gives you full utf8 on your mysql server, after restart it.
Troubleshooting
- 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):
- mysql_new.cnf
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"