mysql 进阶

本文详细介绍了如何在Linux(CentOS)环境下,通过二进制格式安装MySQL,包括创建用户和组、设置环境变量、初始化数据库以及配置服务启动脚本。此外,还阐述了如何破解MySQL数据库密码,通过编辑配置文件、更新用户密码并重新启动服务来实现。
摘要由CSDN通过智能技术生成

##mysql 进阶
###二进制格式mysql安装
下载二进制格式的mysql软件包 (包要去mysql . com 官网查询)

[root@localhost src]#  ls
anaconda-ks.cfg  mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz

创建用户和组

[root@localhost src]#  useradd -M -r -s /sbin/nologin   mysql
[root@localhost src]# id mysql
uid=994(mysql) gid=991(mysql) groups=991(mysql)

解压软件至/usr/local/

[root@localhost src]# tar xf mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz  -C /usr/local/
[root@localhost src]# cd /usr/local/
[root@localhost local]#  ll
total 0
drwxr-xr-x. 2 root root   6 May 11  2019 bin
drwxr-xr-x. 2 root root   6 May 11  2019 etc
drwxr-xr-x. 2 root root   6 May 11  2019 games
drwxr-xr-x. 2 root root   6 May 11  2019 include
drwxr-xr-x. 2 root root   6 May 11  2019 lib
drwxr-xr-x. 2 root root   6 May 11  2019 lib64
drwxr-xr-x. 2 root root   6 May 11  2019 libexec
drwxr-xr-x. 9 root root 129 Jul 26 21:23 mysql-5.7.37-linux-glibc2.12-x86_64
drwxr-xr-x. 2 root root   6 May 11  2019 sbin
drwxr-xr-x. 5 root root  49 Jun 27 16:46 share
drwxr-xr-x. 2 root root   6 May 11  2019 src

[root@localhost local]# ln -sv mysql-5.7.37-linux-glibc2.12-x86_64/  mysql     //做软连接
'mysql' -> 'mysql-5.7.37-linux-glibc2.12-x86_64/'
[root@localhost local]# ll
total 0
drwxr-xr-x. 2 root root   6 May 11  2019 bin
drwxr-xr-x. 2 root root   6 May 11  2019 etc
drwxr-xr-x. 2 root root   6 May 11  2019 games
drwxr-xr-x. 2 root root   6 May 11  2019 include
drwxr-xr-x. 2 root root   6 May 11  2019 lib
drwxr-xr-x. 2 root root   6 May 11  2019 lib64
drwxr-xr-x. 2 root root   6 May 11  2019 libexec
lrwxrwxrwx. 1 root root  36 Jul 26 21:27 mysql -> mysql-5.7.37-linux-glibc2.12-x86_64/
drwxr-xr-x. 9 root root 129 Jul 26 21:23 mysql-5.7.37-linux-glibc2.12-x86_64
drwxr-xr-x. 2 root root   6 May 11  2019 sbin
drwxr-xr-x. 5 root root  49 Jun 27 16:46 share
drwxr-xr-x. 2 root root   6 May 11  2019 src

修改目录/usr/local/mysql的属主属组

[root@localhost local]# chown -R mysql.mysql mysql  //改myxql
[root@localhost local]# ll mysql -d
lrwxrwxrwx. 1 mysql mysql 36 Jul 27 01:10 mysql -> mysql-5.7.37-linux-glibc2.12-x86_64/
[root@localhost local]# ll
total 0
drwxr-xr-x. 2 root  root    6 May 11  2019 bin
drwxr-xr-x. 2 root  root    6 May 11  2019 etc
drwxr-xr-x. 2 root  root    6 May 11  2019 games
drwxr-xr-x. 2 root  root    6 May 11  2019 include
drwxr-xr-x. 2 root  root    6 May 11  2019 lib
drwxr-xr-x. 2 root  root    6 May 11  2019 lib64
drwxr-xr-x. 2 root  root    6 May 11  2019 libexec
lrwxrwxrwx. 1 mysql mysql  36 Jul 26 21:27 mysql -> mysql-5.7.37-linux-glibc2.12-x86_64/
drwxr-xr-x. 9 root  root  129 Jul 26 21:23 mysql-5.7.37-linux-glibc2.12-x86_64
drwxr-xr-x. 2 root  root    6 May 11  2019 sbin
drwxr-xr-x. 5 root  root   49 Jun 27 16:46 share
drwxr-xr-x. 2 root  root    6 May 11  2019 src
[root@localhost local]# chown -R mysql.mysql mysql-5.7.37-linux-glibc2.12-x86_64/    
[root@localhost local]# ll
total 0
drwxr-xr-x. 2 root  root    6 May 11  2019 bin
drwxr-xr-x. 2 root  root    6 May 11  2019 etc
drwxr-xr-x. 2 root  root    6 May 11  2019 games
drwxr-xr-x. 2 root  root    6 May 11  2019 include
drwxr-xr-x. 2 root  root    6 May 11  2019 lib
drwxr-xr-x. 2 root  root    6 May 11  2019 lib64
drwxr-xr-x. 2 root  root    6 May 11  2019 libexec
lrwxrwxrwx. 1 mysql mysql  36 Jul 26 21:27 mysql -> mysql-5.7.37-linux-glibc2.12-x86_64/
drwxr-xr-x. 9 mysql mysql 129 Jul 26 21:23 mysql-5.7.37-linux-glibc2.12-x86_64
drwxr-xr-x. 2 root  root    6 May 11  2019 sbin
drwxr-xr-x. 5 root
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值