Recently I needed a database for my Raspberry PI and I found out about MariaDB. For those of you who don't know what exactly is MariaDB here is a quote from their website History page:
So basically MariaDB is the continuation of the free version of MySQL project.
I don't know about you but whenever I start using a new product I ask myself what are the best practices - in this case the naming conventions - for that particular product. The answer was coming naturally after reading the following on the MariaDB website: Concusion To avoid any issues the best way is to:
For a more thorough list of best practices for naming see this link.
0 Comments
SELECT
SUBSTRING(st.text, (qs.statement_start_offset/2) + 1, ((CASE statement_end_offset WHEN -1 THEN DATALENGTH(st.text) ELSE qs.statement_end_offset END - qs.statement_start_offset)/2) + 1) AS statement_text , last_execution_time , total_elapsed_time / execution_count AS avg_elapsed_time , execution_count , total_physical_reads , total_logical_reads , total_logical_writes , total_worker_time , total_elapsed_time , creation_time FROM sys.dm_exec_query_stats AS qs CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) st WHERE st.text not like '%dm_exec_query_stats%' -- AND st.dbid = DB_ID('mydatabase') -- filter for a specific database ORDER BY total_elapsed_time / execution_count DESC; -- slowest queries --ORDER BY last_execution_time DESC; -- latest queries This can be used for both Latest Queries or Slower Queries; just use desired ORDER BY line ; EXEC sp_who2
OR SELECT L.request_session_id AS SPID, DB_NAME(L.resource_database_id) AS DatabaseName, O.Name AS LockedObjectName, P.object_id AS LockedObjectId, L.resource_type AS LockedResource, L.request_mode AS LockType, ST.text AS SqlStatementText, ES.login_name AS LoginName, ES.host_name AS HostName, TST.is_user_transaction as IsUserTransaction, AT.name as TransactionName, CN.auth_scheme as AuthenticationMethod FROM sys.dm_tran_locks L JOIN sys.partitions P ON P.hobt_id = L.resource_associated_entity_id JOIN sys.objects O ON O.object_id = P.object_id JOIN sys.dm_exec_sessions ES ON ES.session_id = L.request_session_id JOIN sys.dm_tran_session_transactions TST ON ES.session_id = TST.session_id JOIN sys.dm_tran_active_transactions AT ON TST.transaction_id = AT.transaction_id JOIN sys.dm_exec_connections CN ON CN.session_id = ES.session_id CROSS APPLY sys.dm_exec_sql_text(CN.most_recent_sql_handle) AS ST WHERE resource_database_id = db_id() ORDER BY L.request_session_id As I have two security camera at home (one HD and the other one VGA) I thought it would be nice to save all important events using an old computer and free application available online. As I have an old Dell computer (Pentium 4 with on-board graphics) running Windows XP I tried first some windows programs. First I tried Genius Vision which seems to be a solid program with a lot of useful features and pretty user friendly. The problem was that on XP I got a disk cache error almost every day and the program crashes. Then it requires a lot of resources that will slow down visibly even newer computers (especially the playback application). Also I was not able to use my D-Link VGA camera with it. After that I tried ISpy application but I was not able to see the D-Link camera either. Then I wanted to try something on Linux. As I had an old laptop with Ubuntu I erased everything added a clean new version of Ubuntu. That was my first mistake as ZoneMinder (ZM) - the free application I intended to use on Ubuntu - is not compatible yet with Ubuntu 14.04 (at least not the stable one). I have reverted to Ubuntu 12.04 and after watching a lot of tutorials and read a lot of articles, I was able to have a working ZM application. Believe me it was not easy as I had to run a lot of commands/change permissions and still ZM log shows a lot of errors. During my search I noticed people saying that they installed ZM on the latest Ubuntu version. I thought i should give it a try so I have re-installed Ubuntu 14.04. Now using my experience with previous ZM installation In can tell you this: - ZM will not gonna work out of the box. Whenever I installed it from Ubuntu Software manager it will crash. My idea is that it crashes due to the fact that it is not able to display MySQL "Set root password" window. So I got into manual installation. There I found another error as the MySQL database will not be installed by default (for cases where you want to use your own database) . The trick with manual installation is that you need to add some suggested packages that can be required (in my case MySQL). I start installing MySQL and I considered mysql-server-5.6 to be a good option. Unfortunately it wasn't. ZM requires mysql-server whitch requires mysql-server-5.5. So I have uninstalled mysql-server-5.6 and installed mysql-server-5.5. Well that raised another problem as the installation didn't allow me to downgrade MySQL. Finally I considered useful to put together a document to include all steps required to install ZoneMinder on Ubuntu 14.04. You can find it here: ZoneMinder on Ubuntu 14.04 steps
============================= 1) until 1.28 is released use Snapshots PPA sudo add-apt-repository ppa:iconnor/zoneminder-master 2) increase shared memory for improved zoneminder performance sudo gedit /etc/sysctl.conf - for 128Mb add this line in the first section of the file: kernel.shmmax = 536870912 - for 256Mb add this line in the first section of the file: kernel.shmmax = 1073741824 -save and close the file then run this command: sudo sysctl -p 3) pre-install mysql-server Using Ubuntu software installer the installation may freeze Installing using apt-get will not install mysql by default and no db script will be executed 4) other pre-install library that may NOT be required though x264 5) install zoneminder sudo apt-get install zoneminder 6) if web interface is not accessible then you need to configure it using - first edit the file and correct some bugs gedit /etc/zm/apache.conf - the files should look like this (basically you need to add quotes around the path): Alias /zm "/usr/share/zoneminder" <Directory "/usr/share/zoneminder"> php_flag register_globals off Options Indexes FollowSymLinks <IfModule mod_dir.c> DirectoryIndex index.php </IfModule> </Directory> 7) link the file to Apache conf folder sudo ln -s /etc/zm/apache.conf /etc/apache2/conf-available/zoneminder.conf - then enable it: sudo a2enconf zoneminder 8) for some reason cgi is not enabled in Apache after zoneminder install to correct this run: sudo a2enmod cgi //without this the application is not streaming (view events) 9) restart services in the following order sudo service apache2 stop sudo service zoneminder stop sudo rm -vf /tmp/zm/*.* //remove some invalid files sudo service zoneminder start sudo service apache2 start 10) some commands that I an NOT sure are required sudo adduser www-data video //add Apache user to video group |