{"id":2424,"date":"2021-07-13T22:13:19","date_gmt":"2021-07-14T05:13:19","guid":{"rendered":"https:\/\/doubleecpu.com\/?page_id=2424"},"modified":"2021-07-16T01:53:19","modified_gmt":"2021-07-16T08:53:19","slug":"go-mysql-setup","status":"publish","type":"page","link":"https:\/\/doubleecpu.com\/index.php\/go-mysql-setup\/","title":{"rendered":"GO MYSQL Setup"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Setup MySQL<\/h2>\n\n\n\n<p>To check if MySQL is installed type <br>sudo mysql -v<br>This should output the version <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"647\" height=\"183\" src=\"https:\/\/doubleecpu.com\/wp-content\/uploads\/2021\/07\/image.png\" alt=\"\" class=\"wp-image-2429\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Create a database for the app:<\/h2>\n\n\n\n<p>Create a database to store results of CRUD operations. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">CREATE DATABASE IF NOT EXISTS goappdb;\nUSE goappdb;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Notes on Create Database<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] <em>db_name<\/em> \n   [<em>create_option<\/em>] \n   <em>create_option<\/em>: [DEFAULT] { \n      CHARACTER SET [=] <em>charset_name<\/em> \n     |  COLLATE [=] <em>collation_name<\/em> \n     |  ENCRYPTION [=] {'Y' | 'N'} \n   }<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>CREATE DATABASE creates database with db_name (*Requires CREATE privileges, CREATE SCHEMA is a synonym for CREATE DATABASE, <code>LOCK TABLES<\/code>\u00a0statement will not permit CREATE DATABASE)<\/li><li>CHARACTER SET option specifies the database character set<\/li><li>COLLATE option specifies the default database collation <br>*The default MySQL server character set and collation are utf8mb4 and utf8mb4_0900_ai_ci<\/li><li>ENCRYPTION option defines the default database encryption, which is inherited by tables created in the database. The permitted values are &#8216;Y&#8217; (encryption enabled) and &#8216;N&#8217; (encryption disabled)<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Next add a user for Go App<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">CREATE USER 'goApp'@'localhost' IDENTIFIED BY 'Pa$$w0rd';\nGRANT ALL PRIVILEGES ON goappdb.* TO 'goApp'@'localhost';\nFLUSH PRIVILEGES;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">User Notes<\/h3>\n\n\n\n<p>Specific Privileges can be assigned using<br>GRANT type_of_permission ON database_name.table_name TO &#8216;username&#8217;@&#8217;localhost&#8217;;<\/p>\n\n\n\n<p>type_of_permission:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>ALL PRIVILEGES- as we saw previously, this would allow a MySQL user full access to a designated database (or if no database is selected, global access across the system)<\/li><li>CREATE- allows them to create new tables or databases<\/li><li>DROP- allows them to them to delete tables or databases<\/li><li>DELETE- allows them to delete rows from tables<\/li><li>INSERT- allows them to insert rows into tables<\/li><li>SELECT- allows them to use the&nbsp;<code>SELECT<\/code>&nbsp;command to read through databases<\/li><li>UPDATE- allow them to update table rows<\/li><li>GRANT OPTION- allows them to grant or remove other users\u2019 privileges<\/li><\/ul>\n\n\n\n<p>To remove permissions:<br>REVOKE type_of_permission ON database_name.table_name FROM &#8216;username&#8217;@&#8217;localhost&#8217;;<br>To remove a user:<br>DROP USER &#8216;username&#8217;@&#8217;localhost&#8217;;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Create Tables for the app:<\/h2>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Setup MySQL To check if MySQL is installed type sudo mysql -vThis should output the version Create a database for the app: Create a database to store results of CRUD operations. CREATE DATABASE IF NOT EXISTS goappdb; USE goappdb; Notes on Create Database CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name [create_option] create_option: [DEFAULT] { &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/doubleecpu.com\/index.php\/go-mysql-setup\/\" class=\"more-link\">Read more<span class=\"screen-reader-text\"> &#8220;GO MYSQL Setup&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2424","page","type-page","status-publish","hentry"],"featured_media_urls":[],"_links":{"self":[{"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/pages\/2424","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/comments?post=2424"}],"version-history":[{"count":3,"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/pages\/2424\/revisions"}],"predecessor-version":[{"id":2432,"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/pages\/2424\/revisions\/2432"}],"wp:attachment":[{"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/media?parent=2424"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}