Install MySQL

1. Ubuntu Linux

For Ubuntu 16.04 and later, install MySQL by

sudo apt-get install mysql-server

The mysql-server package includes both a MySQL server and a client. While installing MySQL, it will ask for a root user password. You may use the same login password of Ubuntu. After installing MySQL, it may be configured for better security by running the script

mysql_secure_installation

For simple and standard security setup, the reader may press Y and then ENTER to accept the defaults for all the questions.

2. Slackware Linux

Slackware Linux comes with MySQL preinstalled but it still needs to be configured. Otherwise, Slackware will show an error message for the mysql database when it starts up. In Slackware 14.0 or earlier, configure MySQL by the following steps.

  •  Setup my.cnf: MySQL loads a config file called my.cnf at startup. This file needs to be created when you first set up MySQL. In the /etc directory there are a few sample my.cnf files named my-small.cnf, my-large.cnf, etc. Select a desired version to create a my.cnf file, as in

cp /etc/my-small.cnf /etc/my.cnf

  •  Install Required Databases: Mysql has a required database set which it needs. These are used for user identification etc. To install them use mysql user as superuser and install the initial required databases with the following command.

mysql_install_db

  •  Setup Required System Permissions: This step ensures that the mysql user has ownership of the mysql system.

chown -R mysql.mysql /var/lib/mysql

  •  Make /etc/rc.d/rc.mysqld executable by

chmod 755 /etc/rc.d/rc.mysqld

This will start up the MySQL daemon mysqld automatically on subsequent system boots.

Slackware 14.2 use MariaDB in place of MySQL. MariaDB is basically the same database as MySQL except it is not tied to Oracle. In fact, it still uses mysqld as its daemon name. In Slackware 14.2, MySQL already has a default .cnf file, so Step 1 is no longer needed. Configure MySQL by Steps (2) to (4) listed above. After configuration, start up the MySQL daemon mysqld manually

by/etc/rc.d/rc.mysqld -start

Source: Wang K.C. (2018), Systems Programming in Unix/Linux, Springer; 1st ed. 2018 edition.

Leave a Reply

Your email address will not be published. Required fields are marked *