CentOS7.4下MySQL5.7.28二进制方式安装的方法步骤
Linux系统版本:CentOS7.4
MySQL版本:5.7.28
在Linux平台有RPM包、二进制包、源码包3中安装方式,这一篇文章主要是以RPM包为例来介绍如何在Linux平台下进行MySQL的安装。
下载地址:
https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
[root@localhost~]#rpm-qa|grepmariadb mariadb-libs-5.5.56-2.el7.x86_64 [root@localhost~]#rpm-e--nodepsmariadb-libs-5.5.56-2.el7.x86_64
(2)用root用户登录系统,增加mysql用户和组,数据库安装在此用户下:
[root@localhost~]#groupaddmysql [root@localhost~]#useradd-r-gmysql-s/bin/falsemysql
(3)准备数据目录
以/app/data为例,建议使用逻辑卷
[root@localhost~]#mkdir-p/app/data [root@localhost~]#chownmysql.mysql/app/data/ [root@localhost~]#chmod750/app/data
(4)准备二进制文件:
[root@localhost~]#tarxvfmysql-5.7.28-linux-glibc2.12-x86_64.tar.gz-C/usr/local/ root@localhost~]#cd/usr/local [root@localhostlocal]#ln-svmysql-5.7.28-linux-glibc2.12-x86_64mysql ‘mysql'->‘mysql-5.7.28-linux-glibc2.12-x86_64'
(5)初始化MySQL:
[root@localhost~]#cd/usr/local/mysql [root@localhostmysql]#bin/mysqld--initialize--user=mysql--basedir=/usr/local/mysql--datadir=/app/data 2019-11-03T09:47:18.263716Z0[Warning]TIMESTAMPwithimplicitDEFAULTvalueisdeprecated.Pleaseuse--explicit_defaults_for_timestampserveroption(seedocumentationformoredetails). 2019-11-03T09:47:19.059462Z0[Warning]InnoDB:Newlogfilescreated,LSN=45790 2019-11-03T09:47:19.140866Z0[Warning]InnoDB:Creatingforeignkeyconstraintsystemtables. 2019-11-03T09:47:19.207569Z0[Warning]NoexistingUUIDhasbeenfound,soweassumethatthisisthefirsttimethatthisserverhasbeenstarted.GeneratinganewUUID:ed1cd8ec-fe1e-11e9-8c9c-000c29f8617a. 2019-11-03T09:47:19.209181Z0[Warning]Gtidtableisnotreadytobeused.Table'mysql.gtid_executed'cannotbeopened. 2019-11-03T09:47:19.646366Z0[Warning]CAcertificateca.pemisselfsigned. 2019-11-03T09:47:20.056792Z1[Note]Atemporarypasswordisgeneratedforroot@localhost:rY-6f??#!其中--basedirmysql基础目录--datadirmysql数据存放目录,并创建了root用户的临时密码:rY-6f??#!
(6)开启ssl连接:
[root@localhostmysql]#bin/mysql_ssl_rsa_setup 2019-11-0323:09:55[ERROR]Failedtoaccessdirectorypointedby--datadir.Pleasemakesurethatdirectoryexistsandisaccessiblebymysql_ssl_rsa_setup.Suppliedvalue:/usr/local/mysql/data [root@localhostmysql]#bin/mysql_ssl_rsa_setup--datadir=/app/data命令后面不加参数报错,加了--datadir后不报错
(7)编辑配置文件,保存退出:
[root@localhostmysql]#vim/etc/my.cnf [mysqld] #GENERAL datadir=/app/data socket=/app/data/mysql.sock user=mysql default-storage-engine=InnoDB [mysqld_safe] log-error=/app/data/mysql-error.log pid-file=/app/data/mysqld.pid [client] socket=/app/data/mysql.sock(8)启动MySQL:
[root@localhostmysql]#bin/mysqld_safe--user=mysql&(9)配置环境变量:
[root@localhost~]#vim/etc/profile #添加下面一行 exportPATH=$PATH:/usr/local/mysql/bin [root@localhost~]#source/etc/profile(10)设置开机启动:
[root@localhostmysql]#cpsupport-files/mysql.server/etc/init.d/mysql.server [root@localhostmysql]#chkconfig--addmysql.server(11)测试登录成功:
[root@localhost~]#mysql-uroot-p Enterpassword: WelcometotheMySQLmonitor.Commandsendwith;or\g. YourMySQLconnectionidis2 Serverversion:5.7.28 Copyright(c)2000,2019,Oracleand/oritsaffiliates.Allrightsreserved. OracleisaregisteredtrademarkofOracleCorporationand/orits affiliates.Othernamesmaybetrademarksoftheirrespective owners. Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement. mysql>以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。