安装mysql-5.7.25-linux-glibc2.12

本文提供了一步一步的指导,详细介绍了如何在Linux环境下安装和配置MySQL 5.7版本,包括解压安装包、创建数据目录、配置参数、生成SSL密钥、设置系统路径及配置自动启动等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

该博客转自https://blog.yoodb.com/yoodb/article/detail/1517,感谢老铁!!!!!

安装mysql-5.7.25-linux-glibc2.12

在减压包的时候注意将包压缩到 、/usr/local/ 下面

在官网:http://dev.mysql.com/downloads/mysql/ 中,选择以下版本的mysql下载:

1.png

 

1、解压压缩包到目标位置

--解压压缩包

[root@ecs-1b35-0002 tools]# tar -zxvf mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz

--移动并修改文件名

[root@ecs-1b35-0002 tools]# mv mysql-5.7.25-linux-glibc2.12-x86_64 /usr/local/mysql
[root@ecs-1b35-0002 mysql]# pwd

/home/usr/mysql

 

2、创建数据仓库目录

[root@ecs-1b35-0002 mysql]# mkdir data/mysql

新建mysql用户、组及目录

[root@ecs-1b35-0002 mysql]# groupadd mysql
[root@ecs-1b35-0002 mysql]# useradd -r -s /sbin/nologin -g mysql mysql -d /usr/local/mysql

 

3、改变目录属有者

[root@ecs-1b35-0002 mysql]# chown -R mysql .
[root@ecs-1b35-0002 mysql]# chgrp -R mysql .
[root@ecs-1b35-0002 mysql]# chown -R mysql /data/mysql
[root@ecs-1b35-0002 data]# cd ..
[root@ecs-1b35-0002 mysql]# chown -R mysql data/mysql
[root@ecs-1b35-0002 mysql]# ls
bin  COPYING  data  docs  include  lib  man  README  share  support-files

 

4、配置参数

[root@ecs-1b35-0002 mysql]# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/mysql

2019-01-28T07:37:54.141689Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2019-01-28T07:37:54.468955Z 0 [Warning] InnoDB: New log files created, LSN=45790 2019-01-28T07:37:54.533436Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2019-01-28T07:37:54.599965Z 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: 9fcb80c7-22cf-11e9-92c7-fa163ef336d3. 2019-01-28T07:37:54.602975Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2019-01-28T07:37:54.603403Z 1 [Note] A temporary password is generated for root@localhost: q0_wqowE8gk5
 

此处需要注意记录生成的临时密码,如上文结尾处的:q0_wqowE8gk5

 

5、使用脚本工具生成密钥文件

[root@ecs-1b35-0002 mysql]# bin/mysql_ssl_rsa_setup  --datadir=/usr/local/mysql/data/mysql

Generating a 2048 bit RSA private key
......................................................................+++
..................+++
writing new private key to 'ca-key.pem'
-----
Generating a 2048 bit RSA private key
..................................................................................+++
....................................................+++
writing new private key to 'server-key.pem'
-----
Generating a 2048 bit RSA private key
...............................................+++
....................................+++
writing new private key to 'client-key.pem'
-----

 

6、修改系统配置文件

[root@ecs-1b35-0002 mysql]# cd support-files/
[root@ecs-1b35-0002 support-files]# ls
magic  mysqld_multi.server  mysql-log-rotate  mysql.server
[root@ecs-1b35-0002 support-files]# cp mysql.server /etc/init.d/mysql

 

7、修改以下内容

[root@ecs-1b35-0002 mysql]# vi /etc/my.cnf

[mysqld]

init_connect='SET collation_connection = utf8_unicode_ci'

init_connect='SET NAMES utf8'

character-set-server=utf8

port=3307

datadir=/usr/local/mysql/data/mysql

skip-grant-tables

[root@ecs-1b35-0002 mysql]# /etc/init.d/mysql start

Starting MySQL.Logging to '/home/yoodb/mysql/data/mysql/ecs-1b35-0002.novalocal.err'.

 SUCCESS! 

 

8、启动mysql

[root@ecs-1b35-0002 mysql]#  ln -s /usr/local/mysql/bin/mysql /usr/bin
[root@ecs-1b35-0002 my.cnf.d]# service mysql start
[root@ecs-1b35-0002 mysql]# mysql -hlocalhost -uroot -p
Enter password: 输入生成的临时密码
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.25
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.
--修改密码
mysql> set password=password('yoodb123!@#');
Query OK, 0 rows affected, 1 warning (0.00 sec)
--设置root账户的host地址(修改可以远程连接)
mysql> grant all privileges on *.* to 'root'@'%' identified by 'root';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
Bye

这样就可以使用远程连接数据了。

 

9、添加系统路径

# vim /etc/profile

添加:

export PATH=/home/yoodb/mysql/bin:$PATH
[root@ecs-1b35-0002 mysql]# source /etc/profile

 

10、配置mysql自动启动

[root@ecs-1b35-0002 mysql]# chmod 755 /etc/init.d/mysql
[root@ecs-1b35-0002 mysql]# chkconfig --add mysql
[root@ecs-1b35-0002 mysql]# chkconfig --level 345 mysql on

 

或者另一种安装方式:https://www.2cto.com/database/201806/755762.html

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值