{"id":9725,"date":"2014-03-06T09:18:20","date_gmt":"2014-03-06T14:18:20","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=9725"},"modified":"2014-03-06T09:18:20","modified_gmt":"2014-03-06T14:18:20","slug":"mysql-examples","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=9725","title":{"rendered":"MySQL Examples"},"content":{"rendered":"<div class='toc wptoc'>\n<h2>Contents<\/h2>\n<ol class='toc-odd level-1'>\n\t<li>\n\t\t<a href=\"#Install_mysql_with_yum\">Install mysql with yum<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Allow_Remote_Access\">Allow Remote Access<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Create_Local_User\">Create Local User<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Create_a_Remote_User\">Create a Remote User<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Change_User_Password\">Change User Password<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Create_a_Test_Table\">Create a Test Table<\/a>\n\t<\/li>\n<\/ol>\n<\/ol>\n<\/ol>\n<\/div>\n<div class='wptoc-end'>&nbsp;<\/div>\n<span id=\"Install_mysql_with_yum\"><h3>Install mysql with yum<\/h3><\/span>\n<pre lang=\"bash\">\r\nyum install mysql-server mysql\r\n\r\nservice mysqld start\r\n<\/pre>\n<span id=\"Allow_Remote_Access\"><h3>Allow Remote Access<\/h3><\/span>\n<pre lang=\"bash\">\r\n\/etc\/sysconfig\/iptables:\r\n-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT\r\n\r\nservice iptables restart\r\n<\/pre>\n<span id=\"Create_Local_User\"><h3>Create Local User<\/h3><\/span>\n<pre lang=\"sql\">\r\nCREATE USER 'layer7'@'localhost' IDENTIFIED BY 'welcome1';\r\n\r\nGRANT ALL ON *.* TO 'layer7'@'localhost';\r\n\r\nflush privileges;\r\n<\/pre>\n<span id=\"Create_a_Remote_User\"><h3>Create a Remote User<\/h3><\/span>\n<pre lang=\"sql\">\r\nCREATE USER 'layer7'@'%' IDENTIFIED BY 'layer7';\r\n\r\nGRANT ALL ON *.* TO 'layer7'@'%';\r\n\r\nSET PASSWORD FOR 'layer7'@'%' = PASSWORD('welcome1');\r\n\r\nflush privileges;\r\n<\/pre>\n<span id=\"Change_User_Password\"><h3>Change User Password<\/h3><\/span>\n<pre lang=\"sql\">\r\nSET PASSWORD FOR 'layer7'@'%' = PASSWORD('welcome1');\r\n\r\nflush privileges;\r\n<\/pre>\n<span id=\"Create_a_Test_Table\"><h3>Create a Test Table<\/h3><\/span>\n<pre lang=\"bash\">\r\nmysql -u root\r\n\r\nshow databases;\r\nuse test;\r\n\r\ncreate table test_table(id varchar(6), name varchar(20), desc varchar(64));\r\ninsert into test_table values ('1', 'One');\r\nshow tables;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Install mysql with yum yum install mysql-server mysql service mysqld start Allow Remote Access \/etc\/sysconfig\/iptables: -A INPUT -m state &#8211;state NEW -m tcp -p tcp &#8211;dport 3306 -j ACCEPT service iptables restart Create Local User CREATE USER &#8216;layer7&#8217;@&#8217;localhost&#8217; IDENTIFIED BY &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=9725\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[19],"tags":[],"class_list":["post-9725","post","type-post","status-publish","format-standard","hentry","category-mysql"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8cRUO-2wR","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/9725","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9725"}],"version-history":[{"count":2,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/9725\/revisions"}],"predecessor-version":[{"id":9732,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/9725\/revisions\/9732"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9725"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9725"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9725"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}