{"id":291,"date":"2010-08-17T07:01:40","date_gmt":"2010-08-17T11:01:40","guid":{"rendered":"http:\/\/www.xavignu.com\/?p=291"},"modified":"2010-09-19T04:34:44","modified_gmt":"2010-09-19T08:34:44","slug":"some-basic-mysql","status":"publish","type":"post","link":"https:\/\/www.xavignu.com\/?p=291","title":{"rendered":"Some basic MySQL"},"content":{"rendered":"<p>I don&#8217;t feel like doing a long post today so I&#8217;ll do some basic <a href=\"http:\/\/www.mysql.org\" target=\"_blank\">MySQL<\/a>. First lets change the MySQL prompt. Here is a default MySQL prompt.<\/p>\n<pre>\r\nmysql&gt; use test;\r\nDatabase changed\r\nmysql&gt; select now();\r\n+---------------------+\r\n| now()               |\r\n+---------------------+\r\n| 2010-08-17 06:41:00 | \r\n+---------------------+\r\n1 row in set (0.00 sec)\r\n\r\nmysql&gt; \r\n<\/pre>\n<p>Pretty boring, right? Lets spice this a little bit. Type <b>prompt mysql \\u@\\d><\/b> from the MySQL prompt and lets see what happens.<\/p>\n<pre>\r\nmysql&gt; prompt mysql \\u@\\d&gt;\r\nPROMPT set to 'mysql \\u@\\d&gt;'\r\nmysql root@test&gt; select now() \\G\r\n*************************** 1. row ***************************\r\nnow(): 2010-08-17 06:44:56\r\n1 row in set (0.00 sec)\r\n\r\nmysql root@test&gt;\r\n<\/pre>\n<p>What we just did is modify the MySQL prompt to show us the user and the database being used. This is much more informative than the previous MySQL prompt.<\/p>\n<p>Now what if we wanted to know the uptime of the database. Pretty simple type <b>status;<\/b> and that will give us the time the database has been up.<\/p>\n<pre>\r\n mysql root@test&gt;status;\r\n--------------\r\nmysql  Ver 14.12 Distrib 5.0.75, for debian-linux-gnu (i486) using readline 5.2\r\n\r\nConnection id:          39\r\nCurrent database:       test\r\nCurrent user:           root@localhost\r\nSSL:                    Not in use\r\nCurrent pager:          stdout\r\nUsing outfile:          ''\r\nUsing delimiter:        ;\r\nServer version:         5.0.75-0ubuntu10.5-log (Ubuntu)\r\nProtocol version:       10\r\nConnection:             Localhost via UNIX socket\r\nServer characterset:    latin1\r\nDb     characterset:    latin1\r\nClient characterset:    latin1\r\nConn.  characterset:    latin1\r\nUNIX socket:            \/var\/run\/mysqld\/mysqld.sock\r\nUptime:                 10 min 54 sec\r\n\r\nThreads: 1  Questions: 125  Slow queries: 0  Opens: 34  Flush tables: 1  Open tables: 28  Queries per second avg: 0.191\r\n--------------\r\n\r\nmysql root@test&gt;\r\n<\/pre>\n<p>If we wanted to know the running processes just type: <b>show full processlist \\G<\/b>.<\/p>\n<pre>\r\nmysql root@test>show full processlist \\G\r\n*************************** 1. row ***************************\r\n     Id: 39\r\n   User: root\r\n   Host: localhost\r\n     db: test\r\nCommand: Query\r\n   Time: 0\r\n  State: NULL\r\n   Info: show full processlist\r\n1 row in set (0.00 sec)\r\n\r\nmysql root@test&gt;\r\n<\/pre>\n<p>This is all. I know this is very simple stuff, but didn&#8217;t felt like doing a long and complex post. As usual suggestions are always welcome.<br \/>\nReferences:<\/p>\n<ol>\n<li><a href=\"https:\/\/www.ultraquantix.com\/blog\/2008\/12\/making-the-mysql-prompt-more-useful\/\" target=\"_blank\">https:\/\/www.ultraquantix.com\/blog\/2008\/12\/making-the-mysql-prompt-more-useful\/&#8221;<\/a><\/li>\n<li><a href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/mysql-commands.html\" target=\"_blank\">http:\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/mysql-commands.html<\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>I don&#8217;t feel like doing a long post today so I&#8217;ll do some basic MySQL. First lets change the MySQL prompt. Here is a default MySQL prompt. mysql&gt; use test; Database changed mysql&gt; select now(); +&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+ | now() | +&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+ | 2010-08-17 06:41:00 | +&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+ 1 row in set (0.00 sec) mysql&gt; Pretty boring, right? [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[3],"tags":[22,6,51,23,70],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/pTQgt-4H","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/posts\/291"}],"collection":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=291"}],"version-history":[{"count":0,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/posts\/291\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=291"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}