{"id":7303,"date":"2018-03-31T08:58:50","date_gmt":"2018-03-31T00:58:50","guid":{"rendered":"http:\/\/rmohan.com\/?p=7303"},"modified":"2018-03-31T08:58:50","modified_gmt":"2018-03-31T00:58:50","slug":"mysql-binary-install-centos7","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=7303","title":{"rendered":"MYSQL BINARY INSTALL CENTOS7"},"content":{"rendered":"<p>Environment: Virtual Machine + CentOS 7<\/p>\n<p>1. download binary package, the following mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz link is the official website<\/p>\n<p>cd \/usr\/local\/src<\/p>\n<p>wget https:\/\/dev.mysql.com\/get\/Downloads\/MySQL-5.7\/mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz<br \/>\n2. extract, rename<\/p>\n<p>[root@beta src]# tar zxvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz<\/p>\n<p>[root@beta src]# ls<br \/>\nindex.html?id=471614 mysql-5.7.19-linux-glibc2.12-x86_64 mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz<br \/>\n[root@beta src]# mv mysql-5.7.19-linux-glibc2.12-x86_64 \/usr\/local\/mysql<br \/>\n3. Initialize<\/p>\n<p>[root@beta mysql]# useradd -M -s \/sbin\/nologin mysql<\/p>\n<p>[root@beta mysql]# ls<br \/>\nbin COPYING docs include lib man README share support-files<br \/>\n[root@beta mysql]# mkdir -p \/usr\/local\/mysql\/data\/mysql<br \/>\n[root@beta mysql]# chown mysql \/usr\/local\/mysql\/data\/mysql<br \/>\nThe following step attention to the last sentence:<\/p>\n<p>[root@beta mysql]# .\/bin\/mysqld &#8211;initialize &#8211;user=mysql &#8211;datadir=\/usr\/local\/mysql\/data\/mysql<br \/>\n2017-09-27T03:44:47.999985Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use &#8211;explicit_defaults_for_timestamp server option (see documentation for more details).<br \/>\n2017-09-27T03:44:49.011240Z 0 [Warning] InnoDB: New log files created, LSN=45790<br \/>\n2017-09-27T03:44:49.180334Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.<br \/>\n2017-09-27T03:44:49.245777Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 3649ce8c-a336-11e7-a43f-000c292b2832.<br \/>\n2017-09-27T03:44:49.266053Z 0 [Warning] Gtid table is not ready to be used. Table &#8216;mysql.gtid_executed&#8217; cannot be opened.<br \/>\n2017-09-27T03:44:49.268172Z 1 [Note] A temporary password is generated for root@localhost: ADB&amp;yGx-d8ab<\/p>\n<p>ADB&amp;yGx-d8ab<br \/>\nThen execute:<\/p>\n<p>[root@beta mysql]# .\/bin\/mysql_ssl_rsa_setup &#8211;datadir=usr\/local\/mysql\/data\/mysql<br \/>\nGenerating a 2048 bit RSA private key<br \/>\n&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.+++<br \/>\n&#8230;+++<br \/>\nwriting new private key to &#8216;ca-key.pem&#8217;<br \/>\n&#8212;&#8211;<br \/>\nGenerating a 2048 bit RSA private key<br \/>\n&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.+++<br \/>\n&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.+++<br \/>\nwriting new private key to &#8216;server-key.pem&#8217;<br \/>\n&#8212;&#8211;<br \/>\nGenerating a 2048 bit RSA private key<br \/>\n&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..+++<br \/>\n&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..+++<br \/>\nwriting new private key to &#8216;client-key.pem&#8217;<br \/>\n4. Copy the configuration file and startup script<\/p>\n<p>First check whether there is \/etc\/my.cnf, if not<\/p>\n<p>cp support-files\/my-default.cnf \/etc\/my.cnf<br \/>\nEdit \/etc\/my.cnf, focus on the following changes, the other as far as possible comment out:<\/p>\n<p>basedir = \/usr\/local\/mysql<br \/>\ndatadir = \/\/usr\/local\/mysql\/data\/mysql<br \/>\nsocket = \/tmp\/mysql.sock<br \/>\n2. Start the script<\/p>\n<p>cp support-files\/mysql.server \/etc\/init.d\/mysqld<br \/>\nEdit \/etc\/init.d\/mysqld, only modify the following:<\/p>\n<p>basedir=\/usr\/local\/mysql<br \/>\ndatadir=\/data\/mysql<br \/>\nAdd \/etc\/init.d\/mysqld to the startup item:<\/p>\n<p>[root@beta mysql]# chkconfig &#8211;add mysqld<br \/>\n[root@beta mysql]# chkconfig &#8211;list<\/p>\n<p>systemd &#8216;systemctl list-unit-files&#8217;?<br \/>\ntarget<br \/>\nsystemctl list-dependencies [target]?<\/p>\n<p>5. Start the service<\/p>\n<p>\/etc\/init.d\/mysqld start<br \/>\n6. Set the root password<\/p>\n<p>Log in with the initial password (see step 3 above)<\/p>\n<p>\/usr\/local\/mysql\/bin\/mysql -uroot -p\u2018\u2019 #-p?\u2019\u2019<br \/>\nAppears mysql&gt;, enter set password = password (&#8216;new password&#8217;);<\/p>\n<p>Exit, login with new password<\/p>\n<p>2. Forget the initial password<\/p>\n<p>To \/etc\/my.cnf\/[mysqld] Add a line below skip-grant-tables, restart mysqld: \/etc\/init.d\/mysqld restart<\/p>\n<p>[mysqld]<br \/>\nskip-grant-tables<br \/>\nbasedir=\/usr\/local\/mysql<br \/>\ndatadir=\/usr\/local\/mysql\/data\/mysql<br \/>\nsocket=\/tmp\/mysql.sock<\/p>\n<p>[root@beta ~]# \/etc\/init.d\/mysqld restart<br \/>\nShutting down MySQL.. SUCCESS!<br \/>\nStarting MySQL.. SUCCESS!<br \/>\nRe-login mysql:<\/p>\n<p>[root@beta ~]# \/usr\/local\/mysql\/bin\/mysql -uroot<br \/>\nmysql&gt; enter: update mysql.user set authentication_string = password (&#8216;123333&#8217;) where user = &#8216;root&#8217;;<\/p>\n<p>mysql&gt; update mysql.user set authentication_string=password(&#8216;123333&#8242;) where user=&#8217;root&#8217;;<br \/>\nQuery OK, 1 row affected, 1 warning (0.00 sec)<br \/>\nRows matched: 1 Changed: 1 Warnings: 1<br \/>\nQuit, delete my.cnf added skip-grant-tables, restart mysqld<\/p>\n<p>New password re-login mysql:<\/p>\n<p>[root@beta ~]# \/usr\/local\/mysql\/bin\/mysql -uroot -p&#8217;123333&#8242;<br \/>\nmysql: [Warning] Using a password on the command line interface can be insecure.<br \/>\nWelcome to the MySQL monitor. Commands end with ; or \\g.<br \/>\nYour MySQL connection id is 13<br \/>\nServer version: 5.7.19 MySQL Community Server (GPL)<\/p>\n<p>Copyright (c) 2000, 2017, Oracle and\/or its affiliates. All rights reserved.<\/p>\n<p>Oracle is a registered trademark of Oracle Corporation and\/or its<br \/>\naffiliates. Other names may be trademarks of their respective<br \/>\nowners.<\/p>\n<p>Type &#8216;help;&#8217; or &#8216;\\h&#8217; for help. Type &#8216;\\c&#8217; to clear the current input statement.<\/p>\n<p>mysql&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Environment: Virtual Machine + CentOS 7<\/p>\n<p>1. download binary package, the following mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz link is the official website<\/p>\n<p>cd \/usr\/local\/src<\/p>\n<p>wget https:\/\/dev.mysql.com\/get\/Downloads\/MySQL-5.7\/mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz 2. extract, rename<\/p>\n<p>[root@beta src]# tar zxvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz<\/p>\n<p>[root@beta src]# ls index.html?id=471614 mysql-5.7.19-linux-glibc2.12-x86_64 mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz [root@beta src]# mv mysql-5.7.19-linux-glibc2.12-x86_64 \/usr\/local\/mysql 3. Initialize<\/p>\n<p>[root@beta mysql]# useradd -M -s \/sbin\/nologin mysql<\/p>\n<p>[root@beta mysql]# ls bin COPYING [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7303"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7303"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7303\/revisions"}],"predecessor-version":[{"id":7304,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7303\/revisions\/7304"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}