{"id":3579,"date":"2012-07-20T00:35:08","date_gmt":"2012-07-19T16:35:08","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=3579"},"modified":"2023-04-28T09:49:02","modified_gmt":"2023-04-28T09:49:02","slug":"how-to-install-and-securing-mysql-database-server-on-centos-6-3","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-install-and-securing-mysql-database-server-on-centos-6-3\/","title":{"rendered":"How to Install and Securing MySQL Database Server on CentOS 6.3"},"content":{"rendered":"<p>This post will covers the steps to install and securing MySQL Database Server. MySQL server is a database server that can stores and retrieves data for the blog, websites and applications. It is one of the most popular most used in the internet especially for content management and blogging site. MySQL is a Relational Database Management System (RDBMS) that runs as a server providing multi-user access to a number of databases. For more information on MySQL, you can visit their website at www.mysql.com.<\/p>\n<p><strong>Prerequisites :<\/strong><br \/>\n<a href=\"https:\/\/webhostinggeeks.com\/howto\/how-to-setup-and-configure-yum-repository-from-cd-romdvd-rom-image-on-centos-6-3\/\">How to Setup and Configure Yum Repository from CD-ROM\/DVD-ROM image on CentOS 6.3<\/a><\/p>\n<p>1. Install MySQL Database Server using yum command :<\/p>\n<pre>\n[root@centos63 ~]# yum install mysql mysql-server -y\n<\/pre>\n<p>Examples :<\/p>\n<pre>\n[root@centos63 ~]# yum install mysql mysql-server -y\nLoaded plugins: fastestmirror, presto\nLoading mirror speeds from cached hostfile\n * base: mirrors.hostemo.com\n * extras: mirrors.hostemo.com\n * updates: mirrors.hostemo.com\nCentOS6.3-Repository                                                         | 4.0 kB     00:00 ...\nSetting up Install Process\nResolving Dependencies\n--> Running transaction check\n---> Package mysql.i686 0:5.1.61-4.el6 will be installed\n--> Processing Dependency: mysql-libs = 5.1.61-4.el6 for package: mysql-5.1.61-4.el6.i686\n--> Processing Dependency: libmysqlclient_r.so.16(libmysqlclient_16) for package: mysql-5.1.61-4.el6.i686\n--> Processing Dependency: libmysqlclient_r.so.16 for package: mysql-5.1.61-4.el6.i686\n--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16) for package: mysql-5.1.61-4.el6.i686\n--> Processing Dependency: libmysqlclient.so.16 for package: mysql-5.1.61-4.el6.i686\n---> Package mysql-server.i686 0:5.1.61-4.el6 will be installed\n--> Processing Dependency: perl-DBI for package: mysql-server-5.1.61-4.el6.i686\n--> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.61-4.el6.i686\n--> Processing Dependency: perl(DBI) for package: mysql-server-5.1.61-4.el6.i686\n--> Running transaction check\n---> Package mysql-libs.i686 0:5.1.61-4.el6 will be installed\n---> Package perl-DBD-MySQL.i686 0:4.013-3.el6 will be installed\n---> Package perl-DBI.i686 0:1.609-4.el6 will be installed\n--> Finished Dependency Resolution\n\nDependencies Resolved\n\n====================================================================================================\n Package                 Arch          Version                  Repository                     Size\n====================================================================================================\nInstalling:\n mysql                   i686          5.1.61-4.el6             CentOS6.3-Repository          892 k\n mysql-server            i686          5.1.61-4.el6             CentOS6.3-Repository          8.8 M\nInstalling for dependencies:\n mysql-libs              i686          5.1.61-4.el6             CentOS6.3-Repository          1.2 M\n perl-DBD-MySQL          i686          4.013-3.el6              CentOS6.3-Repository          134 k\n perl-DBI                i686          1.609-4.el6              CentOS6.3-Repository          705 k\n\nTransaction Summary\n====================================================================================================\nInstall       5 Package(s)\n\nTotal download size: 12 M\nInstalled size: 33 M\nDownloading Packages:\nSetting up and reading Presto delta metadata\nProcessing delta metadata\nPackage(s) data still to download: 12 M\n----------------------------------------------------------------------------------------------------\nTotal                                                                22 MB\/s |  12 MB     00:00\nRunning rpm_check_debug\nRunning Transaction Test\nTransaction Test Succeeded\nRunning Transaction\n  Installing : mysql-libs-5.1.61-4.el6.i686                                                     1\/5\n  Installing : perl-DBI-1.609-4.el6.i686                                                        2\/5\n  Installing : perl-DBD-MySQL-4.013-3.el6.i686                                                  3\/5\n  Installing : mysql-5.1.61-4.el6.i686                                                          4\/5\n  Installing : mysql-server-5.1.61-4.el6.i686                                                   5\/5\n  Verifying  : mysql-server-5.1.61-4.el6.i686                                                   1\/5\n  Verifying  : perl-DBD-MySQL-4.013-3.el6.i686                                                  2\/5\n  Verifying  : perl-DBI-1.609-4.el6.i686                                                        3\/5\n  Verifying  : mysql-5.1.61-4.el6.i686                                                          4\/5\n  Verifying  : mysql-libs-5.1.61-4.el6.i686                                                     5\/5\n\nInstalled:\n  mysql.i686 0:5.1.61-4.el6                     mysql-server.i686 0:5.1.61-4.el6\n\nDependency Installed:\n  mysql-libs.i686 0:5.1.61-4.el6   perl-DBD-MySQL.i686 0:4.013-3.el6   perl-DBI.i686 0:1.609-4.el6\n\nComplete!\n<\/pre>\n<p>2. Start MySQL Database Server :<\/p>\n<pre>\n[root@centos63 ~]# \/etc\/init.d\/mysqld start\n<\/pre>\n<p>or<\/p>\n<pre>\n[root@centos63 ~]# service mysqld start\n<\/pre>\n<p>Examples :<\/p>\n<p>Starting MySQL for first time will returned like this :<\/p>\n<pre>\n[root@centos63 ~]# \/etc\/init.d\/mysqld start\nInitializing MySQL database:  WARNING: The host 'centos63.ehowstuff.local' could not be looked up with resolveip.\nThis probably means that your libc libraries are not 100 % compatible\nwith this binary MySQL version. The MySQL daemon, mysqld, should work\nnormally with the exception that host name resolving will not work.\nThis means that you should use IP addresses instead of hostnames\nwhen specifying MySQL privileges !\nInstalling MySQL system tables...\nOK\nFilling help tables...\nOK\n\nTo start mysqld at boot time you have to copy\nsupport-files\/mysql.server to the right place for your system\n\nPLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !\nTo do so, start the server, then issue the following commands:\n\n\/usr\/bin\/mysqladmin -u root password 'new-password'\n\/usr\/bin\/mysqladmin -u root -h centos63.ehowstuff.local password 'new-password'\n\nAlternatively you can run:\n\/usr\/bin\/mysql_secure_installation\n\nwhich will also give you the option of removing the test\ndatabases and anonymous user created by default.  This is\nstrongly recommended for production servers.\n\nSee the manual for more instructions.\n\nYou can start the MySQL daemon with:\ncd \/usr ; \/usr\/bin\/mysqld_safe &\n\nYou can test the MySQL daemon with mysql-test-run.pl\ncd \/usr\/mysql-test ; perl mysql-test-run.pl\n\nPlease report any problems with the \/usr\/bin\/mysqlbug script!\n\n                                                           [  OK  ]\nStarting mysqld:                                           [  OK  ]\n<\/pre>\n<p>3. Make MySQL Database Server auto start at boot :<\/p>\n<pre>\n[root@centos63 ~]# chkconfig mysqld on\n<\/pre>\n<p>4. Securing MySQL Database Server :<\/p>\n<pre>\n[root@centos63 ~]# \/usr\/bin\/mysql_secure_installation\n<\/pre>\n<p>Examples :<\/p>\n<pre>\n[root@centos63 ~]# \/usr\/bin\/mysql_secure_installation\n\n\n\n\nNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL\n      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!\n\n\nIn order to log into MySQL to secure it, we'll need the current\npassword for the root user.  If you've just installed MySQL, and\nyou haven't set the root password yet, the password will be blank,\nso you should just press enter here.\n\nEnter current password for root (enter for none):\nOK, successfully used password, moving on...\n\nSetting the root password ensures that nobody can log into the MySQL\nroot user without the proper authorisation.\n\nSet root password? [Y\/n] y\nNew password:\nRe-enter new password:\nPassword updated successfully!\nReloading privilege tables..\n ... Success!\n\n\nBy default, a MySQL installation has an anonymous user, allowing anyone\nto log into MySQL without having to have a user account created for\nthem.  This is intended only for testing, and to make the installation\ngo a bit smoother.  You should remove them before moving into a\nproduction environment.\n\nRemove anonymous users? [Y\/n] y\n ... Success!\n\nNormally, root should only be allowed to connect from 'localhost'.  This\nensures that someone cannot guess at the root password from the network.\n\nDisallow root login remotely? [Y\/n] y\n ... Success!\n\nBy default, MySQL comes with a database named 'test' that anyone can\naccess.  This is also intended only for testing, and should be removed\nbefore moving into a production environment.\n\nRemove test database and access to it? [Y\/n] y\n - Dropping test database...\n ... Success!\n - Removing privileges on test database...\n ... Success!\n\nReloading the privilege tables will ensure that all changes made so far\nwill take effect immediately.\n\nReload privilege tables now? [Y\/n] y\n ... Success!\n\nCleaning up...\n\n\n\nAll done!  If you've completed all of the above steps, your MySQL\ninstallation should now be secure.\n\nThanks for using MySQL!\n\n\n<\/pre>\n<p>5. Login to MySQL Server :<\/p>\n<pre>\n[root@centos63 ~]# mysql -u root -p\nEnter password:\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 10\nServer version: 5.1.61 Source distribution\n\nCopyright (c) 2000, 2011, Oracle and\/or its affiliates. All rights reserved.\n\nOracle is a registered trademark of Oracle Corporation and\/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This post will covers the steps to install and securing MySQL Database Server. MySQL server is a database server that can stores and retrieves data for the blog, websites and&#8230;<\/p>\n","protected":false},"author":6,"featured_media":343,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[1008],"tags":[1254,1536,1546,1585],"class_list":["post-3579","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mysql","tag-centos-6-3","tag-linux","tag-linux-utilities","tag-mysql"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/3579","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=3579"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/3579\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/343"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=3579"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=3579"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=3579"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}