Linux 安装Mysql5.6教程

1、下载mysql

选择对应的包 如下5.6包
下载官方 Mysql 包
https://downloads.mysql.com/archives/community/
在这里插入图片描述

mysql:5.6百度云盘链接:https://pan.baidu.com/s/1F_9_FNpW60htO6ojh8LX2g?pwd=ag22
提取码:ag22

2、创建mysql用户组和mysql用户

groupadd mysql && useradd -r -g mysql mysql

3、上传解压,并初始化

#解压软件包并改名
tar -zxvf mysql-5.6.44-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
mv /usr/local/mysql-5.6.44-linux-glibc2.12-x86_64 /usr/local/mysql
#创建数据目录并赋予权限
mkdir -p /data/mysql
chown mysql:mysql -R /data/mysql
#修改配置文件
cat > /etc/my.cnf << EOF
[mysqld]
port=3306
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql
socket=/tmp/mysql.sock
log-error=/data/mysql/mysql.err
pid-file=/data/mysql/mysql.pid
#character config
character_set_server=utf8mb4
symbolic-links=0
explicit_defaults_for_timestamp=true
EOF
#安装初始化依赖
yum -y install autoconf make perl
#执行初始化
cd /usr/local/mysql/scripts/
./mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql

其中: --defaults-file 指定配置文件

–basedir指定Mysql安装目录

–datadir指定数据目录

–user所属用户

4、启动mysql

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
service mysql start

5、 修改密码

[root@bbb scripts]#  /usr/local/mysql/bin/mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.44 MySQL Community Server (GPL)

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> update mysql.user set Password=password('mysql') where Host='localhost' and User='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye
  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值