Linux MySQL 5.7.23安装

(0)上传安装包

 

具体安装步骤如下:

(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)准备二进制文件:

[root@localhost ~]# tar xvf mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz -C /home/envir/mysql
root@localhost ~]# cd /home/envir

 (4)准备数据目录

以/envir/mysql/data为例,建议使用逻辑卷

[root@localhost ~]# mkdir -p /home/envir/mysql/data
[root@localhost ~]# chown mysql.mysql /home/envir/mysql/data/
[root@localhost ~]# chmod 750 /home/envir/mysql/data

(5)初始化MySQL:

[root@localhost ~]# cd /home/envir/mysql
[root@localhost mysql]# bin/mysqld --initialize --user=mysql --basedir=/home/envir/mysql --datadir=/home/envir/mysql/data
2019-12-25T10:05:24.760645Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-12-25T10:05:25.076527Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-12-25T10:05:25.121880Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-12-25T10:05:25.185707Z 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: 11e2f5fc-26fe-11ea-8c17-000c293f6419.
2019-12-25T10:05:25.186463Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-12-25T10:05:25.187232Z 1 [Note] A temporary password is generated for root@localhost: rx%NrgdCC6cq

其中--basedir mysql基础目录 --datadir mysql数据存放目录,

并创建了root用户的临时密码:rx%NrgdCC6cq

 

启动mysql服务命令是会报错的,因为没有修改mysql的配置文件,报错内容大致如下:

./support-files/mysql.server: line 239: my_print_defaults: command not found

./support-files/mysql.server: line 259: cd: /usr/local/mysql: No such file or directory

Starting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)

 (6)编辑或者新增 /etc/my.cnf 文件在我的资源里 如果你的安装路径 为/home/envir/mysql 可以直接覆盖

资源链接 https://download.csdn.net/download/BovinLee/12375874

(7)将mysql加入服务

cp /home/envir/mysql/support-files/mysql.server /etc/init.d/mysql

 (7.1)/etc/init.d/mysql如下:修改其内容 mysql的路径 

basedir 或 datadir 为你的按照路径 如果你的安装路径为/home/envir/mysql 可以直接覆盖

资源链接  https://download.csdn.net/download/BovinLee/12375894

(9)开机自启

chkconfig mysql on

(10) 启动MYSQL服务

service mysql start

(11)设置Mysql root密码

# 登录 ,使用上面的临时密码

/home/envir/mysql/bin/mysql -u root -p

(11-1)操作mysql数据库

use mysql;
#修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '修改后的密码'
或者
set password for root@localhost = password('yourpass');

 

(13)退出

exit;

(14)测试修改后的密码

/home/envir/mysql/bin/mysql -u root -p

显示信息:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 4

Server version: 5.7.23 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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.

(15)允许远程连接

update user set host='%' where user = 'root';
 flush privileges;

文档:Linux MySQL 5.7.23安装 (成功).note
链接:http://note.youdao.com/noteshare?id=c97ff8c13ad1022e3562adbf4ebedc0f&sub=D5A73970D4B84E25BDA2DA96FD1F8B49 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值