Creating A New MySQL User, Database, and Granting Permissions

March 27, 2017 MySQL No comments , , ,

In this example, I am creating a new database called moodle and it’s own user named moodle for accessing it.

Note: This is for a test/development machine on localhost. In the string IDENTIFIED BY 'moodle' you may wish to replace moodle with a real password.

mysql> CREATE DATABASE moodle;
Query OK, 1 row affected (0.00 sec)

mysql> SELECT user,password,host FROM mysql.user;
+-----------+-------------------------------------------+-----------+
| user      | password                                  | host      |
+-----------+-------------------------------------------+-----------+
| root      | *<41 byte password hash>                  | localhost |
| root      | *<41 byte password hash>                  | 127.0.0.1 |
| sakaiuser | *<41 byte password hash>                  | localhost |
| sakaiuser | *<41 byte password hash>                  | 127.0.0.1 |
| olat      | *2D665452229FB636D7CACCE3273269E34C62CA5C | localhost |
| olat      | *2D665452229FB636D7CACCE3273269E34C62CA5C | 127.0.0.1 |
+-----------+-------------------------------------------+-----------+
10 rows in set (0.00 sec)

mysql> CREATE USER 'moodle'@'localhost' IDENTIFIED BY 'moodle';
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE USER 'moodle'@'127.0.0.1' IDENTIFIED BY 'moodle';
Query OK, 0 rows affected (0.02 sec)

mysql> GRANT ALL PRIVILEGES ON moodle.* TO 'moodle'@'localhost' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON moodle.* TO 'moodle'@'127.0.0.1' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW GRANTS FOR 'moodle'@'localhost';
+---------------------------------------------------------------------------------------------------------------+
| Grants for moodle@localhost                                                                                   |
+---------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'moodle'@'localhost' IDENTIFIED BY PASSWORD '*1ECDE898A7068C6422AF1220D301EBA14F576CF9' |
| GRANT ALL PRIVILEGES ON `moodle`.* TO 'moodle'@'localhost' WITH GRANT OPTION                                  |
+---------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

mysql> SHOW GRANTS FOR 'moodle'@'127.0.0.1';
+---------------------------------------------------------------------------------------------------------------+
| Grants for moodle@127.0.0.1                                                                                   |
+---------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'moodle'@'127.0.0.1' IDENTIFIED BY PASSWORD '*1ECDE898A7068C6422AF1220D301EBA14F576CF9' |
| GRANT ALL PRIVILEGES ON `moodle`.* TO 'moodle'@'127.0.0.1' WITH GRANT OPTION                                  |
+---------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

mysql> exit;
Bye

Recovering WordPress After Changing ‘WordPress Address URL’

March 26, 2017 MySQL, WordPress No comments , ,

I learned that apparently if you change the WordPress Address (URL) field in Settings, you can actually cripple the site completely. Not only does your content fail to load, but you can’t even reach the admin interface.

I had removed the trailing /blog portion of the URL to cause this. So how do you fix it? Edit the database.

[alureon.pi] ~http % mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5532
Server version: 10.1.21-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> USE wordpress;
Database changed
MariaDB [wordpress]> SELECT * FROM `wp_options` WHERE option_name = "siteurl";
+-----------+-------------+--------------------+----------+
| option_id | option_name | option_value       | autoload |
+-----------+-------------+--------------------+----------+
|         1 | siteurl     | http://alureon.net | yes      |
+-----------+-------------+--------------------+----------+
1 row in set (0.00 sec)

MariaDB [wordpress]> UPDATE `wp_options` SET option_value = "http://alureon.net/blog" WHERE option_name = "siteurl";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [wordpress]> SELECT * FROM `wp_options` WHERE option_name = "siteurl";
+-----------+-------------+-------------------------+----------+
| option_id | option_name | option_value            | autoload |
+-----------+-------------+-------------------------+----------+
|         1 | siteurl     | http://alureon.net/blog | yes      |
+-----------+-------------+-------------------------+----------+
1 row in set (0.00 sec)

MariaDB [wordpress]> exit;
Bye

Not a terrible pain in the neck, but more manual intervention than most people probably want to deal with.

Fixing Pretty Permalinks with WordPress and Apache Web Server

March 26, 2017 Apache, Linux, WordPress No comments , , , ,

Apparently, in order to use pretty permalinks in WordPress, (with Apache Webserver…) you can’t simply “enable the option” in WordPress and expect it to work. You have to make the following changes to your httpsd.conf. In my case, this was located at /etc/httpsd/conf/httpsd.conf.

  1. Uncomment LoadModule rewrite_module modules/mod_rewrite.so
  2. Enable FollowSymLinks for your WordPress directory.
  3. Enable AllowOverride to either All or FileInfo. The relevant configurtion section for these steps is as follows:
        <Directory "/srv/https">
        #
        # Possible values for the Options directive are "None", "All",
        # or any combination of:
        #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
        #
        # Note that "MultiViews" must be named *explicitly* --- "Options All"
        # doesn't give it to you.
        #
        # The Options directive is both complicated and important.  Please see
        # https://httpsd.apache.org/docs/2.4/mod/core.html#options
        # for more information.
        #
        Options Indexes FollowSymLinks

        #
        # AllowOverride controls what directives may be placed in .htaccess files.
        # It can be "All", "None", or any combination of the keywords:
        #   AllowOverride FileInfo AuthConfig Limit
        #
        AllowOverride All

        #
        # Controls who can get stuff from this server.
        #
        Require all granted
        </Directory>

That should do the trick. The only other caveat is that WordPress needs a .htaccess as well. Fortunately, as long as WordPress has write permissions, it can make its own! I just restarted my web server and viola!

Terrifying deadly plant

March 6, 2015 Uncategorized

The “doll’s eyes” plant produces cardiogenic toxins that have a sedative effect on the heart.  If eaten by a human, it causes cardiac arrest and death.

If that wasn’t bad enough, it also looks terrifying.

Source:  Wikipedia – Actaea pachypoda