CentOS7.4下MySQL5.7.28二进制方式安装的方法步骤
程序员文章站
2022-06-23 20:25:03
linux系统版本:centos7.4
mysql版本:5.7.28
在linux平台有rpm包、二进制包、源码包3中安装方式,这一篇文章主要是以rpm包为例来介绍如何在l...
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
具体安装步骤如下:
(1)首先卸载mariadb,不然后面会和安装mysql需要的库冲突:
[root@localhost ~]# rpm -qa | grep mariadb mariadb-libs-5.5.56-2.el7.x86_64 [root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
(2)用root用户登录系统,增加mysql用户和组,数据库安装在此用户下:
[root@localhost ~]# groupadd mysql [root@localhost ~]# useradd -r -g mysql -s /bin/false mysql
(3)准备数据目录
以/app/data为例,建议使用逻辑卷
[root@localhost ~]# mkdir -p /app/data [root@localhost ~]# chown mysql.mysql /app/data/ [root@localhost ~]# chmod 750 /app/data
(4)准备二进制文件:
[root@localhost ~]# tar xvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz -c /usr/local/ root@localhost ~]# cd /usr/local [root@localhost local]# ln -sv mysql-5.7.28-linux-glibc2.12-x86_64 mysql ‘mysql' -> ‘mysql-5.7.28-linux-glibc2.12-x86_64'
(5)初始化mysql:
[root@localhost ~]# cd /usr/local/mysql [root@localhost mysql]# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/app/data 2019-11-03t09:47:18.263716z 0 [warning] timestamp with implicit default value is deprecated. please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2019-11-03t09:47:19.059462z 0 [warning] innodb: new log files created, lsn=45790 2019-11-03t09:47:19.140866z 0 [warning] innodb: creating foreign key constraint system tables. 2019-11-03t09:47:19.207569z 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: ed1cd8ec-fe1e-11e9-8c9c-000c29f8617a. 2019-11-03t09:47:19.209181z 0 [warning] gtid table is not ready to be used. table 'mysql.gtid_executed' cannot be opened. 2019-11-03t09:47:19.646366z 0 [warning] ca certificate ca.pem is self signed. 2019-11-03t09:47:20.056792z 1 [note] a temporary password is generated for root@localhost: ry-6f??#!<zo
其中--basedir mysql基础目录 --datadir mysql数据存放目录,并创建了root用户的临时密码:ry-6f??#!<zo
(6)开启ssl连接:
[root@localhost mysql]# bin/mysql_ssl_rsa_setup 2019-11-03 23:09:55 [error] failed to access directory pointed by --datadir. please make sure that directory exists and is accessible by mysql_ssl_rsa_setup. supplied value : /usr/local/mysql/data [root@localhost mysql]# bin/mysql_ssl_rsa_setup --datadir=/app/data
命令后面不加参数报错,加了--datadir后不报错
(7)编辑配置文件,保存退出:
[root@localhost mysql]# 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@localhost mysql]# bin/mysqld_safe --user=mysql &
(9)配置环境变量:
[root@localhost ~]# vim /etc/profile #添加下面一行 export path=$path:/usr/local/mysql/bin [root@localhost ~]# source /etc/profile
(10)设置开机启动:
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysql.server [root@localhost mysql]# chkconfig --add mysql.server
(11)测试登录成功:
[root@localhost ~]# mysql -uroot -p enter password: welcome to the mysql monitor. commands end with ; or \g. your mysql connection id is 2 server version: 5.7.28 copyright (c) 2000, 2019, oracle and/or its affiliates. all rights reserved. oracle is a registered trademark of oracle corporation and/or its affiliates. other names may be trademarks of their respective owners. type 'help;' or '\h' for help. type '\c' to clear the current input statement. mysql>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
上一篇: 长帝电烤箱价格配得上做出美食