Skip to content

Installation: sql db for Fedora

acozine edited this page Jun 20, 2013 · 36 revisions

We recommend using mysql, so that's what the instructions reflect.

  1. Install mysql-server
    Ubuntu: sudo apt-get install mysql-server
    CentOS: sudo yum install mysql-server
  2. Note the version of mysql-server you installed - it's listed in the download/install output
  3. Secure mysql-server and set a root password.
    Ubuntu: the installer will prompt you to set a root password.
    CentOS: start mysql with sudo service mysqld start, then run /usr/bin/mysql_secure_installation and follow the prompts to set the password and secure the db
  4. (CentOS only) Set mysql to run automatically on startup/reboot sudo chkconfig mysqld on
  5. Move mysql, configure data directory sudo service mysqld stop
    sudo cp -a /var/lib/mysql/ /opt/
    sudo mkdir /etc/mysql
    sudo mv /etc/my.cnf /etc/mysql/
  6. Edit /etc/mysql/my.cnf and change the data directory line to read:
    datadir=/opt/mysql
  7. Configure mysql for fedora
    1. set storage to InnoDB
      sudo mkdir /etc/mysql/conf.d
      Copy and paste the following block into your terminal window and hit enter

cat << EOF | sudo tee /etc/mysql/conf.d/innodb_engine.cnf [mysqld] default-storage-engine = InnoDB EOF ```
1. Set character set to utf8
These variables are for mysql v 5.4 or lower – for >=5.5, use [mysqld] character-set-server, for >= 5.6 use `[client] character_set_client`
Copy and paste the following block into your terminal window and hit enter

    ```bash 

cat << EOF | sudo tee /etc/mysql/conf.d/utf8_charset.cnf [mysqld]
default-character-set=utf8
[client]
default-character-set=utf8
EOF ```

  1. Confirm permissions for mysql directory and contents: sudo chown -R mysql:mysql /opt/mysql
  2. Restart mysql sudo service mysqld start
    CentOS NOTE: if you have trouble restarting mysqld, please confirm that SELinux is disabled.
  3. Create the mysql databases for fedora. Log in to mysql: mysql -u root -p
    Enter mysql root pw, which you set when you configured mysql-server. These instructions are shown with the mysql prompt and the expected output. To copy the commands into your shell, copy everything AFTER the > up to the semicolon; the expected output is shown in italics.
    mysql> CREATE DATABASE hydradam_test;
    Query OK, 1 row affected (0.00 sec)
    mysql>
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON hydradam_test.* TO hdTests@localhost IDENTIFIED BY 'hdTests';

Query OK, 0 rows affected (0.00 sec)
mysql> CREATE DATABASE fedora3;
Query OK, 1 row affected (0.00 sec)
mysql> GRANT ALL ON fedora3.* TO fedoraDBAdmin@localhost IDENTIFIED BY 'fedoraAdmin';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT ALL ON fedora3.* TO fedoraDBAdmin@'%' IDENTIFIED BY 'fedoraAdmin';
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye

Clone this wiki locally