{"id":3090,"date":"2013-05-27T20:20:38","date_gmt":"2013-05-27T20:20:38","guid":{"rendered":"http:\/\/blog.shineservers.com\/?p=149"},"modified":"2013-05-27T20:20:38","modified_gmt":"2013-05-27T20:20:38","slug":"centos-6-mysql-server-phpmyadmin","status":"publish","type":"post","link":"https:\/\/www.shineservers.com\/2013\/05\/27\/centos-6-mysql-server-phpmyadmin\/","title":{"rendered":"CentOS 6 &#8211; MySQL Server &#038; PHPMyAdmin"},"content":{"rendered":"<h2>Install and Configure<\/h2>\n<h3>Notes<\/h3>\n<p>If you already have MySQL installed from the yum repositories, then you won&#8217;t be able to follow this guide as your MySQL version is too old. Please see\u00a0<a href=\"http:\/\/blog.iphoting.com\/blog\/2012\/06\/19\/upgrading-to-mysql-5-dot-5-on-centos-6\/\" target=\"new\" rel=\"noopener noreferrer\">[here]<\/a>\u00a0which may be able to help you (untested).<\/p>\n<h3>Environment<\/h3>\n<p>Fresh install of\u00a0<a href=\"http:\/\/www.centos.org\/modules\/tinycontent\/index.php?id=34\" target=\"new\" rel=\"noopener noreferrer\">CentOS-6.3-x86_64-minimal<\/a>\u00a0with the latest updates\u00a0<code>yum update -y<\/code><\/p>\n<blockquote>\n<pre># uname -sro\nLinux 2.6.32-279.22.1.el6.x86_64 GNU\/Linux<\/pre>\n<\/blockquote>\n<p>I have also disabled SELINUX. Please see\u00a0<a href=\"http:\/\/www.itmanx.com\/kb\/centos6\/selinux\">[here]<\/a>\u00a0for a guide.<\/p>\n<h3>Prerequisites<\/h3>\n<h4>Additional Repositories<\/h4>\n<p>Nb. You can check for the latest EPEL repository from\u00a0<a href=\"http:\/\/mirror.datacenter.by\/pub\/fedoraproject.org\/epel\/6\/x86_64\/repoview\/epel-release.html\">http:\/\/mirror.datacenter.by\/pub\/fedoraproject.org\/epel\/6\/x86_64\/repoview\/epel-release.html<\/a><\/p>\n<blockquote>\n<div>rpm -ivh http:\/\/mirror.datacenter.by\/pub\/fedoraproject.org\/epel\/6\/x86_64\/epel-release-6-8.noarch.rpm rpm -ivh http:\/\/rpms.famillecollet.com\/enterprise\/remi-release-6.rpm<\/div>\n<\/blockquote>\n<p>Then you need to enable the REMI repository<\/p>\n<div>nano \/etc\/yum.repos.d\/remi.repo<\/div>\n<blockquote>\n<pre>[remi]\nenabled=1<\/pre>\n<\/blockquote>\n<h4>Additional Packages<\/h4>\n<p>I used\u00a0<strong>nano<\/strong>\u00a0as the text editor, but you can just as easily use\u00a0<strong>vi<\/strong>\u00a0if you are familiar with it.<\/p>\n<blockquote>\n<div>yum install -y wget nano perl<\/div>\n<\/blockquote>\n<h4>Configure Firewall<\/h4>\n<div>nano \/etc\/sysconfig\/iptables<\/div>\n<p><em>Make sure you add any other rules you are using which aren&#8217;t listed here.<\/em><\/p>\n<blockquote>\n<pre>*filter\n:INPUT ACCEPT [0:0]\n:FORWARD ACCEPT [0:0]\n:OUTPUT ACCEPT [0:0]\n-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT\n-A INPUT -p icmp -j ACCEPT\n-A INPUT -i lo -j ACCEPT\n-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT\n\n-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT\n-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT\n\n# Uncomment the following line to allow direct remote access to your mysql server, \n# changing -s 192.168.0.0\/16 to your own network or remove it to allow access from anywhere\n# This has serious security implications so only do it if you know what you're doing\n#-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT -s 192.168.0.0\/16\n\n-A INPUT -j REJECT --reject-with icmp-host-prohibited\n-A FORWARD -j REJECT --reject-with icmp-host-prohibited\nCOMMIT<\/pre>\n<\/blockquote>\n<div><strong>service iptables restart<\/strong><\/div>\n<h4>Create SSL Certificates<\/h4>\n<blockquote>\n<div>mkdir \/etc\/ssl\/certs\/mysql<br \/>\nopenssl req -new -nodes -x509 -keyout \/etc\/ssl\/certs\/ca-cert.pem -out \/etc\/ssl\/certs\/ca-cert.pem -days 3650<br \/>\nopenssl req -new -nodes -days 3650 -keyout \/etc\/ssl\/certs\/mysql\/server-key.pem -out \/etc\/ssl\/certs\/mysql\/server-req.pem openssl rsa -in \/etc\/ssl\/certs\/mysql\/server-key.pem -out \/etc\/ssl\/certs\/mysql\/server-key.pem openssl x509 -req -in \/etc\/ssl\/certs\/mysql\/server-req.pem -CA \/etc\/ssl\/certs\/ca-cert.pem -CAcreateserial -days 3650 -out \/etc\/ssl\/certs\/mysql\/server-cert.pem<br \/>\nopenssl req -new -nodes -days 3650 -keyout \/etc\/ssl\/certs\/mysql\/client-key.pem -out \/etc\/ssl\/certs\/mysql\/client-req.pem openssl rsa -in \/etc\/ssl\/certs\/mysql\/client-key.pem -out \/etc\/ssl\/certs\/mysql\/client-key.pem openssl x509 -req -in \/etc\/ssl\/certs\/mysql\/client-req.pem -CA \/etc\/ssl\/certs\/ca-cert.pem -CAcreateserial -days 3650 -out \/etc\/ssl\/certs\/mysql\/client-cert.pem<\/div>\n<\/blockquote>\n<p>Example of what to fill in but input your own answers.<\/p>\n<pre><a href=\"http:\/\/en.wikipedia.org\/wiki\/ISO_3166-1_alpha-2#Officially_assigned_code_elements\" target=\"new\" rel=\"noopener noreferrer\">Country Name (2 letter code)<\/a> [XX]:IM\nState or Province Name (full name) []:Isle of Man\nLocality Name (eg, city) [Default City]:Colby\nOrganization Name (eg, company) [Default Company Ltd]:ITManx Ltd\nOrganizational Unit Name (eg, section) []:ICT\nCommon Name (eg, your name or your server's hostname) []:secure.itmanx.com\nEmail Address []:support@itmanx.com\n\n* You will get asked the following on the server and client certificates created. Leave these blank!\nA challenge password []:\nAn optional company name []:<\/pre>\n<p>You can test the certificate is ok by typing<\/p>\n<div>openssl verify -CAfile \/etc\/ssl\/certs\/ca-cert.pem \/etc\/ssl\/certs\/mysql\/server-cert.pem \/etc\/ssl\/certs\/mysql\/client-cert.pem<\/div>\n<blockquote>\n<pre>\/etc\/ssl\/certs\/mysql\/server-cert.pem: OK\n\/etc\/ssl\/certs\/mysql\/client-cert.pem: OK<\/pre>\n<\/blockquote>\n<h3>Install<\/h3>\n<h4>MySQL<\/h4>\n<p>At the time of writing, the version of MySQL in the CentOS yum repositories was version 5.1 which is near\u00a0<abbr title=\"End of life\">EOL<\/abbr>\u00a0so don&#8217;t use it unless you have to.<\/p>\n<p>If you would prefer to have the latest version of MySQL, then see the note below instead<\/p>\n<blockquote>\n<div>yum install -y mysql mysql-server<\/div>\n<\/blockquote>\n<p><strong>Note:<\/strong>\u00a0To install the latest version of MySQL, you can get the latest version of MySQL from\u00a0<a href=\"http:\/\/dev.mysql.com\/downloads\/mysql\/#downloads\" target=\"new\" rel=\"noopener noreferrer\">http:\/\/dev.mysql.com\/downloads\/mysql\/#downloads<\/a>(select Red Hat Linux 6) and note you need Server, Client and Compatibility Libraries<\/p>\n<blockquote>\n<div>rpm -ivf http:\/\/dev.mysql.com\/get\/Downloads\/MySQL-5.6\/MySQL-server-5.6.10-1.el6.x86_64.rpm\/from\/http:\/\/cdn.mysql.com\/ rpm -ivf http:\/\/dev.mysql.com\/get\/Downloads\/MySQL-5.6\/MySQL-client-5.6.10-1.el6.x86_64.rpm\/from\/http:\/\/cdn.mysql.com\/ rpm -ivf http:\/\/dev.mysql.com\/get\/Downloads\/MySQL-5.6\/MySQL-shared-compat-5.6.10-1.el6.x86_64.rpm\/from\/http:\/\/cdn.mysql.com\/<\/div>\n<\/blockquote>\n<p>The installation creates a random root password which you can see in\u00a0<strong>\/root\/.mysql_secret<\/strong><\/p>\n<div>mv \/usr\/my.cnf \/usr\/my.cnf.original nano \/usr\/my.cnf<\/div>\n<blockquote>\n<pre>[client]\nssl_ca=\/etc\/pki\/tls\/certs\/ca-cert.pem\nssl_cert=\/etc\/pki\/tls\/certs\/mysql\/client-cert.pem\nssl_key=\/etc\/pki\/tls\/certs\/mysql\/client-key.pem\n\n[mysqld]\n# Set to the amount of RAM for the most important data cache in MySQL.\n# Start at 70% of total RAM for dedicated server, else 10%.\ninnodb_buffer_pool_size = 128M\n\ndatadir=\/var\/lib\/mysql\nsocket=\/var\/lib\/mysql\/mysql.sock\n\nsql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES\n\ncharacter_set_server=utf8\n\nssl_ca=\/etc\/pki\/tls\/certs\/ca-cert.pem\nssl_cert=\/etc\/pki\/tls\/certs\/mysql\/server-cert.pem\nssl_key=\/etc\/pki\/tls\/certs\/mysql\/server-key.pem\n\n[mysqld_safe]\nlog-error=\/var\/log\/mysqld.log\npid-file=\/var\/run\/mysqld\/mysqld.pid<\/pre>\n<\/blockquote>\n<div>service mysql start<\/div>\n<p>Take a look at the log file to make sure no start-up errors<\/p>\n<div>cat \/var\/log\/mysqld.log<\/div>\n<p>Now grab the pre-set password and login<\/p>\n<blockquote>\n<div>cat \/root\/.mysql_secret<\/div>\n<div>mysql -u root -p ** enter the password from \/root\/.mysql_secret<\/div>\n<\/blockquote>\n<p>Change\u00a0<strong>mypassword<\/strong>\u00a0to your own password. The password should be at least 10 characters. You can generate a password\u00a0<a href=\"http:\/\/www.pctools.com\/guides\/password\/?length=12&amp;alpha=on&amp;mixedcase=on&amp;numeric=on&amp;punctuation=on&amp;nosimilar=on&amp;quantity=5&amp;generate=true\" target=\"new\" rel=\"noopener noreferrer\">[here]<\/a>.<\/p>\n<blockquote>\n<pre>SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('mypassword');\nSET PASSWORD FOR 'root'@'::1' = PASSWORD('mypassword');\nSET PASSWORD FOR 'root'@'localhost' = PASSWORD('mypassword');\nDROP DATABASE test;\nquit<\/pre>\n<\/blockquote>\n<h4>phpMyAdmin<\/h4>\n<blockquote>\n<div>yum install -y httpd mod_ssl php php-mysql php-mcrypt php-mbstring php-gd<\/div>\n<\/blockquote>\n<p>You can get the latest version from\u00a0<a href=\"http:\/\/www.phpmyadmin.net\/home_page\/downloads.php\" target=\"new\" rel=\"noopener noreferrer\">http:\/\/www.phpmyadmin.net\/home_page\/downloads.php<\/a><\/p>\n<blockquote>\n<div>cd \/var\/www\/html wget http:\/\/sourceforge.net\/projects\/phpmyadmin\/files\/phpMyAdmin\/3.5.7\/phpMyAdmin-3.5.7-all-languages.tar.bz2\/download tar -jxvf phpMyAdmin-* rm -f php*.bz2 mv phpMyAdmin-* phpmyadmin cp phpmyadmin\/config.sample.inc.php phpmyadmin\/config.inc.php<\/div>\n<div>nano \/etc\/httpd\/conf.d\/phpmyadmin.conf<\/div>\n<\/blockquote>\n<pre>Alias \/phpmyadmin \/var\/www\/html\/phpmyadmin\n\n&lt;Directory \/var\/www\/html\/phpmyadmin&gt;\n Options -Indexes\n&lt;\/Directory&gt;\n\n&lt;Directory \/var\/www\/html\/phpmyadmin\/setup&gt;\n Order Deny,Allow\n Deny from All\n&lt;\/Directory&gt;\n\n&lt;Directory \/var\/www\/html\/phpmyadmin\/libraries&gt;\n Order Deny,Allow\n Deny from All\n&lt;\/Directory&gt;<\/pre>\n<div>nano \/var\/www\/html\/phpmyadmin\/config.inc.php<\/div>\n<p>The password can be up to 46 characters. You can generate a password\u00a0<a href=\"http:\/\/www.pctools.com\/guides\/password\/?length=46&amp;alpha=on&amp;mixedcase=on&amp;numeric=on&amp;punctuation=on&amp;nosimilar=on&amp;quantity=5&amp;generate=true\" target=\"new\" rel=\"noopener noreferrer\">[here]<\/a>.<\/p>\n<blockquote>\n<pre>$cfg['blowfish_secret'] = '5@#@7ecr39R@musU99GAkE+!ASt63$aB+es3zedu_ep$ey'\t \/* Change to your own password *\/<\/pre>\n<\/blockquote>\n<div>nano \/etc\/php.ini<\/div>\n<p>Search for\u00a0<strong>date.timezone<\/strong>\u00a0and set it to your timezone. See\u00a0<a href=\"http:\/\/www.php.net\/manual\/en\/timezones.php\" target=\"new\" rel=\"noopener noreferrer\">[here]<\/a>\u00a0for a list of timezones.<\/p>\n<blockquote>\n<div>date.timezone = UTC<\/div>\n<div>chkconfig httpd on service httpd start<\/div>\n<\/blockquote>\n<h3>Test<\/h3>\n<p>Log in to\u00a0<strong>https:\/\/webserver\/phpmyadmin\/<\/strong>\u00a0with username\u00a0<strong>root<\/strong>\u00a0and the password you set when configuring MySQL earlier.<\/p>\n<h3>Monitor<\/h3>\n<h4>Resources<\/h4>\n<p>Type\u00a0<strong>top<\/strong>\u00a0to view resources or better yet, install htop\u00a0<code>yum install -y htop<\/code>\u00a0and then type\u00a0<strong>htop<\/strong>\u00a0(see at the bottom for filter and enter\u00a0<strong>mysql<\/strong>)<\/p>\n<h4>Live Queries<\/h4>\n<p>If you want to log live queries, you can enable logging in the MySQL configuration file.<\/p>\n<p>&nbsp;<\/p>\n<p>BE AWARE THAT THIS WILL LOG EVERY QUERY PASSED TO THE MYSQL SERVER SO WILL QUICKLY CONSUME FREE DISK SPACE AND SLOW PERFORMANCE!<\/p>\n<div>touch \/var\/log\/mysql.log chown mysql:mysql \/var\/log\/mysql.log<\/div>\n<div>nano \/usr\/my.cnf<\/div>\n<pre>[mysqld]\n.....\ngeneral_log=1\ngeneral_log_file=\/var\/log\/mysql.log<\/pre>\n<div>service mysqld reload<\/div>\n<p>You can then view live queries by typing\u00a0<code>tail -f \/var\/log\/mysql.log<\/code><\/p>\n<h4>System Resource Monitoring<\/h4>\n<p>Install\u00a0<strong>htop<\/strong>\u00a0to see system resource usage<\/p>\n<blockquote>\n<div>yum install -y htop<\/div>\n<\/blockquote>\n<p>Run by typing\u00a0<code>htop<\/code><\/p>\n<p>&nbsp;<\/p>\n<h3>Reference<\/h3>\n<p><a href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.6\/en\/linux-installation-rpm.html\" target=\"new\" rel=\"noopener noreferrer\">http:\/\/dev.mysql.com\/doc\/refman\/5.6\/en\/linux-installation-rpm.html<\/a><\/p>\n<p><a href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.6\/en\/creating-ssl-certs.html\" target=\"new\" rel=\"noopener noreferrer\">http:\/\/dev.mysql.com\/doc\/refman\/5.6\/en\/creating-ssl-certs.html<\/a><\/p>\n<p><a href=\"http:\/\/www.openssl.org\/docs\/apps\/req.html\" target=\"new\" rel=\"noopener noreferrer\">http:\/\/www.openssl.org\/docs\/apps\/req.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Install and Configure Notes If you already have MySQL installed from the yum repositories, then you won&#8217;t be able to follow this guide as your MySQL version is too old. Please see\u00a0[here]\u00a0which may be able to help you (untested). Environment Fresh install of\u00a0CentOS-6.3-x86_64-minimal\u00a0with the latest updates\u00a0yum update -y # uname -sro Linux 2.6.32-279.22.1.el6.x86_64 GNU\/Linux I [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[60],"tags":[79],"class_list":["post-3090","post","type-post","status-publish","format-standard","hentry","category-linux","tag-mysql-server-install-centos"],"acf":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts\/3090","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/comments?post=3090"}],"version-history":[{"count":0,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts\/3090\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/media?parent=3090"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/categories?post=3090"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/tags?post=3090"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}