Advertisement
Barry_IA

BE3 - MariaDB - May 20

May 20th, 2019
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.23 KB | None | 0 0
  1.  
  2.  
  3. Re: BE3 - Issues with installation and database
  4.  
  5. Hi Stephen!
  6.  
  7. Sorry, the "show database" problem was mine - I left the ; off the end of the command. The "mysql", "information_schema" and "performance_schema" databases are all internal databases used by
  8. MariaDB to run itself. They are real databases, and you can look at the contents if you want to. But they are automatically created by MariaDB when it is installed.
  9. After I ‘discovered’ the problem was the lack of the semi-colon figured it was just a ‘shorthand’: all part of my learning! ...Wasn’t sure on the databases (and other ‘excess’ information); sometimes what one sees (or doesn’t see) is important but I don’t have the experience to know and so give it to someone who does.
  10.  
  11.  
  12. <snip>
  13. sudo nano /tmp/mc.sql
  14.  
  15. At the start of the file, add this line: DROP DATABASE IF EXISTS mythconverg;
  16. Command already inserted. Just doing ‘live commentary’; the /tmp file was not present prior to me creating this morning.
  17.  
  18. In the both the lines with the clause IDENTIFIED BY "mythtv";
  19. change "mythtv" to be the password in your /etc/mythtv/config.xml file.
  20.  
  21. Sort of as a follow-up to the above, the password field was ‘mythtv’ originally.
  22.  
  23. Then shut down mythbackend, if it is running: sudo systemctl stop mythtv-backend
  24. Immediately back to command line. (No delay noted.)
  25.  
  26. Make sure MariaDB is running: sudo systemctl status mariadb
  27. Active….
  28.  
  29. Then run these commands:
  30. sudo mysql
  31. source /tmp/mc.sql
  32. quit
  33.  
  34. Note that the source and quit commands do not have a ; terminator. The source command reads the mc.sql file and sends the commands in it to mysqld one line at a time to be executed.
  35.  
  36. That should delete the old database (if there is one) and create a new mythconverg database and set it up correctly. But will not create all the tables in the database. When you start mythbackend:
  37.  
  38. sudo systemctl start mythtv-backend
  39.  
  40. that should then be able to connect to MariaDB and create and populate all the tables used by mythbackend. The next time you run mythfrontend, it should create and populate all the tables used only by mythfrontend and its frontend only plugins (such as mythmusic).
  41.  
  42. As an alternative to running mythbackend, if you run mythtv-setup, it should also create and populate all the backend database tables when it sees they are not there.
  43.  
  44. When you have been previously running mythtv-setup, I am guessing that it was unable to create and populate the mythconverg database because it did not have the correct permissions. The GRANT command done in mc.sql should fix that. However, if you are intending to run mythfrontend on other PCs and connect back to this backend box, you will need to provide permission for external connections to the database. To do that, you would need to change the first GRANT line in your copy of mc.sql to:
  45.  
  46. GRANT ALL ON mythconverg.* TO mythtv@'%' IDENTIFIED BY "mythtv";
  47.  
  48. (with the correct password in the IDENTIFIED BY clause).
  49.  
  50. You can also add the extra permissions later at any time by doing:
  51.  
  52. sudo mysql
  53. GRANT ALL ON mythconverg.* TO mythtv@'%' IDENTIFIED BY "mythtv";
  54. FLUSH PERMISSIONS;
  55. quit
  56.  
  57. Note that if you do it later, the second GRANT command will add a second (wider) set of permissions - the original mythtv@localhost permissions will remain in the permissions database. You can see all the GRANTs in MariaDB by doing this:
  58.  
  59. sudo mysql
  60. show grants;
  61. quit
  62.  
  63. In SQL strings, the % character is used to match string of zero or more characters, so '%' is a string that will match against any string of characters. So using it in the GRANT command after the @ symbol tells MariaDB to match any IP address as having that permission. The name on the left of the @ symbol is the username that is matched in that GRANT. Unless you change it, mythbackend always uses the username 'mythtv'. So mythtv@'%' allows the mythtv user to login to MariaDB from any IP address. You can use a more limited range of IP addresses, if you prefer. For example, if your network uses the 192.168.*.* addresses, then you could put mythtv@'192.168.%' to only allow access from your local network.
  64.  
  65. ------------------------------
  66.  
  67.  
  68. For some reason still displays as “Mariadb [(none)]>” – may not be exact but know ‘mythconverg’ should be where ‘name’ is.
  69. Try rebooting to reload. Still ‘none’. :(
  70. /tmp/mc.sql gone on reboot – was going to show you my work should I have made an error.
  71.  
  72. Recreate /tmp/mc.sql….
  73. Ah! The first line is “Create”, not “drop’! ==> mc_sql.txt
  74.  
  75. DROP DATABASE IF EXISTS mythconverg;
  76. CREATE DATABASE IF NOT EXISTS mythconverg;
  77. GRANT ALL ON mythconverg.* TO mythtv@'%' IDENTIFIED BY "Z******S";
  78. FLUSH PRIVILEGES;
  79. GRANT CREATE TEMPORARY TABLES ON mythconverg.* TO mythtv@localhost IDENTIFIED BY "Z******S";
  80. FLUSH PRIVILEGES;
  81. ALTER DATABASE mythconverg DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
  82.  
  83. (Password partially obliterated)
  84. Line 3 '%' for running with other Frontends.
  85.  
  86. At sudo mysql source /tmp/mc.sql quit steps prior to ‘quit’ still displays MariaDB [(none)].
  87. barry@Backend-3:~$ sudo mysql
  88. Welcome to the MariaDB monitor. Commands end with ; or \g.
  89. Your MariaDB connection id is 31
  90. Server version: 10.1.38-MariaDB-0ubuntu0.18.04.2 Ubuntu 18.04
  91.  
  92. Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
  93.  
  94. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  95.  
  96. MariaDB [(none)]> source /tmp/mc.sql
  97. Query OK, 0 rows affected (0.01 sec)
  98.  
  99. Query OK, 1 row affected (0.00 sec)
  100.  
  101. Query OK, 0 rows affected (0.01 sec)
  102.  
  103. Query OK, 0 rows affected (0.00 sec)
  104.  
  105. Query OK, 0 rows affected (0.01 sec)
  106.  
  107. Query OK, 0 rows affected (0.00 sec)
  108.  
  109. Query OK, 1 row affected (0.00 sec)
  110.  
  111. MariaDB [(none)]> quit
  112. Bye
  113. barry@Backend-3:~$
  114.  
  115. sudo systemctl start mythtv-backend ==> immediate to Terminal prompt
  116.  
  117. At sudo mysql show grants; quit steps:
  118.  
  119.  
  120. barry@Backend-3:~$ sudo mysql
  121. Welcome to the MariaDB monitor. Commands end with ; or \g.
  122. Your MariaDB connection id is 32
  123. Server version: 10.1.38-MariaDB-0ubuntu0.18.04.2 Ubuntu 18.04
  124.  
  125. Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
  126.  
  127. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  128.  
  129. MariaDB [(none)]> show grants;
  130. +------------------------------------------------------------------------------------------------+
  131. | Grants for root@localhost |
  132. +------------------------------------------------------------------------------------------------+
  133. | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED VIA unix_socket WITH GRANT OPTION |
  134. | GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION |
  135. +------------------------------------------------------------------------------------------------+
  136. 2 rows in set (0.00 sec)
  137.  
  138. MariaDB [(none)]>
  139.  
  140. Obviously still not connecting/seeing mythconverg.
  141. <grumble><mumble> Take a break.
  142. Try altering /tmp/mc.sql from mythtv@localhost to mythtv@192.168.0.3 (Line 5):
  143.  
  144. DROP DATABASE IF EXISTS mythconverg;
  145. CREATE DATABASE IF NOT EXISTS mythconverg;
  146. GRANT ALL ON mythconverg.* TO mythtv@'%' IDENTIFIED BY "Z******S";
  147. FLUSH PRIVILEGES;
  148. GRANT CREATE TEMPORARY TABLES ON mythconverg.* TO mythtv@192.168.0.3 IDENTIFIED BY "Z******S";
  149. FLUSH PRIVILEGES;
  150. ALTER DATABASE mythconverg DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
  151.  
  152. Then shut down mythbackend, if it is running: sudo systemctl stop mythtv-backend
  153. Immediately back to command line. (No delay noted.)
  154.  
  155. Make sure MariaDB is running: sudo systemctl status mariadb
  156.  
  157. ● mariadb.service - MariaDB 10.1.38 database server
  158. Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
  159. Active: active (running) since Mon 2019-05-20 08:31:00 CDT; 1h 49min ago
  160. Docs: man:mysqld(8)
  161. https://mariadb.com/kb/en/library/systemd/
  162. Process: 1131 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  163. Process: 1128 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
  164. Process: 924 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ] && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code
  165. Process: 912 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  166. Process: 894 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
  167. Main PID: 1062 (mysqld)
  168. Status: "Taking your SQL requests now..."
  169. Tasks: 27 (limit: 4915)
  170. CGroup: /system.slice/mariadb.service
  171. └─1062 /usr/sbin/mysqld
  172.  
  173. May 20 08:30:54 Backend-3 systemd[1]: Starting MariaDB 10.1.38 database server...
  174. May 20 08:30:56 Backend-3 mysqld[1062]: 2019-05-20 8:30:56 140166783814784 [Note] /usr/sbin/mysqld (mysqld 10.1.38-MariaDB-0ubuntu0.18.04.2) starting as process 1062 ...
  175. May 20 08:31:00 Backend-3 systemd[1]: Started MariaDB 10.1.38 database server.
  176. May 20 08:31:01 Backend-3 /etc/mysql/debian-start[1134]: /usr/bin/mysql_upgrade: the '--basedir' option is always ignored
  177. May 20 08:31:01 Backend-3 /etc/mysql/debian-start[1134]: Looking for 'mysql' as: /usr/bin/mysql
  178. May 20 08:31:01 Backend-3 /etc/mysql/debian-start[1134]: Looking for 'mysqlcheck' as: /usr/bin/mysqlcheck
  179. May 20 08:31:01 Backend-3 /etc/mysql/debian-start[1134]: This installation of MySQL is already upgraded to 10.1.38-MariaDB, use --force if you still need to run mysql_upgrade
  180. May 20 08:31:01 Backend-3 /etc/mysql/debian-start[1180]: Checking for insecure root accounts.
  181. May 20 08:31:01 Backend-3 /etc/mysql/debian-start[1185]: Triggering myisam-recover for all MyISAM tables and aria-recover for all Aria tables
  182. ~
  183. ~
  184.  
  185.  
  186. Why showing 8:30 (a.m.) when it’s two hours later and I've played with stuff???
  187. Ran the rest of the commands but nothing changed.
  188. sudo mysql still displays MariaDB [(none)], so know still not seeing mythconverg
  189.  
  190. Reboot.
  191.  
  192. Still ‘none’.
  193.  
  194. Upload this reply to let you find out where I misunderstood something.
  195.  
  196. Thanks!
  197. Barry
  198.  
  199. Received automated error message: Message body is too big: 50392 bytes with a limit of 40 KB
  200. Decided to post here.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement