linux下安装mysql5.7,详细步骤,附安装包

1.mysql5.7安装包

链接:https://pan.baidu.com/s/1xvtk5OkK4c93bP8w9mIUMQ 
提取码:iv2q

2.将安装包上传到服务器并解压

[root@iZwz9br4vz6tthgk5jupa6Z mysql]# tar -zxvf mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz

linux下安装mysql5.7,详细步骤,附安装包_第1张图片

在这里插入图片描述

3.修改文件夹名称,重命名

[root@iZwz9br4vz6tthgk5jupa6Z mysql]# mv mysql-5.7.35-linux-glibc2.12-x86_64 mysql

在这里插入图片描述

4.查看是否存在mysql组

[root@iZwz9br4vz6tthgk5jupa6Z mysql]# cat /etc/group | grep mysql
[root@iZwz9br4vz6tthgk5jupa6Z mysql]# cat /etc/passwd | grep mysql

在这里插入图片描述
没有则创建


[root@iZwz9br4vz6tthgk5jupa6Z mysql]# groupadd mysql
groupadd: group 'mysql' already exists
[root@iZwz9br4vz6tthgk5jupa6Z mysql]# useradd -r -g mysql mysql
useradd: user 'mysql' already exists
[root@iZwz9br4vz6tthgk5jupa6Z mysql]#

在这里插入图片描述

5.创建data目录

[root@iZwz9br4vz6tthgk5jupa6Z mysql]# mkdir data

在这里插入图片描述

6.修改mysql所有者及所属组为mysql

chown -R mysql.mysql /usr/local/mysql/mysql

在这里插入图片描述

7.编辑vim /etc/my.cnf文件

vim /etc/my.cnf

添加下面内容:

[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

basedir = /usr/local/mysql/mysql
datadir = /usr/local/mysql/mysql/data
port = 33061
socket = /tmp/mysql.sock
character-set-server=utf8

log-error = /usr/local/mysql/mysql/data/mysqld.log
pid-file = /usr/local/mysql/mysql/data/mysqld.pid

linux下安装mysql5.7,详细步骤,附安装包_第2张图片
linux下安装mysql5.7,详细步骤,附安装包_第3张图片

8.安装libaio

[root@iZwz9br4vz6tthgk5jupa6Z mysql]# yum install libaio

linux下安装mysql5.7,详细步骤,附安装包_第4张图片

9.初始化mysql

[root@iZwz9br4vz6tthgk5jupa6Z mysql]# ./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/mysql/ --datadir=/usr/local/mysql/mysql/data/

在这里插入图片描述

10.查看日志

[root@iZwz9br4vz6tthgk5jupa6Z mysql]# cat /usr/local/mysql/mysql/data/mysqld.log

右下查看临时密码:
linux下安装mysql5.7,详细步骤,附安装包_第5张图片

2021-10-27T01:14:37.321305Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-10-27T01:14:37.321395Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2021-10-27T01:14:37.321399Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2021-10-27T01:14:38.375914Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-10-27T01:14:38.556683Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-10-27T01:14:38.627168Z 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: 4173c545-36c3-11ec-8b39-00163e04480e.
2021-10-27T01:14:38.631909Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-10-27T01:14:39.065173Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2021-10-27T01:14:39.065187Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2021-10-27T01:14:39.065874Z 0 [Warning] CA certificate ca.pem is self signed.
2021-10-27T01:14:39.193949Z 1 [Note] A temporary password is generated for root@localhost: s2Jcufq&JDZG

11.把启动脚本放到初始化目录

[root@iZwz9br4vz6tthgk5jupa6Z mysql]# cp support-files/mysql.server /etc/init.d/mysql

在这里插入图片描述

12.启动mysql

[root@iZwz9br4vz6tthgk5jupa6Z mysql]# service mysql start

在这里插入图片描述

登录mysql

[root@iZwz9br4vz6tthgk5jupa6Z mysql]# ./bin/mysql -u root -p

在这里插入图片描述
linux下安装mysql5.7,详细步骤,附安装包_第6张图片

13.设置密码

mysql> set password=password('root');

linux下安装mysql5.7,详细步骤,附安装包_第7张图片
在这里插入图片描述
设置远程可访问

mysql> grant all privileges on *.* to root@'%' identified by 'root';

在这里插入图片描述
使配置生效

mysql> flush privileges;

在这里插入图片描述
重启mysql
在这里插入图片描述

mysql> service mysql restart

你可能感兴趣的:(mysql,linux,数据库)