mysql装到centos7上遇到的坑(下载慢,No such file or directory,ERROR 2002 (HY000),临时密码过期)

今天打算学个mysql的高级,结果安装mysql花了一下午。。。

遇到的坑:

一 、下载的速度超级慢

解决办法:

找百度云别人下好的包(mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz),例如:

https://pan.baidu.com/s/1Tit3J-0pJfVCdzfKJxTc4w  提取码是:t049

二、service mysqld start提示

Redirecting to /bin/systemctl start  mysqld.service
Failed to issue method call: Unit mysqld.service failed to load: No such file or directory.

这个折磨我了好久

解决办法:

把mysql的进程杀完之后

[root@centos11 mysql]# cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@centos11 mysql]# chmod +x /etc/rc.d/init.d/mysqld
[root@centos11 mysql]# chkconfig --add mysqld
[root@centos11 mysql]# chkconfig --list mysqld

注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。
      如果您想列出 systemd 服务,请执行 'systemctl list-unit-files'。
      欲查看对特定 target 启用的服务请执行
      'systemctl list-dependencies [target]'。

mysqld          0:关    1:关    2:开    3:开    4:开    5:开    6:关

然后再运行服务启动命令就可以了
[root@centos11 mysql]# service mysqld start
Starting MySQL.... SUCCESS!

原本以为这就结束了,结果更坑爹的还在后面

三、登录的时候报ERROR 2002 (HY000):...'/var/lib/mysql/mysql.sock' (2)

[root@centos11 mysql]# mysql -uroot -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

解决办法:

1)、查找 mysql.sock所在位置:

[root@centos11 mysql]# find / -name '*.sock'
/tmp/mysql.sock

2)、在报错的位置创建对应的文件

mkdir /var/lib/mysql/

注意不要创建mysql.sock这个文件,创建后面还是会报错

3)、把这两个文件链接起来

ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock

然后就可以准备登录了!!!!好开心

 

你以为这就结束了,还有大坑,西八

四、临时密码过期

我们在初始化mysql的时候会产生一个临时密码


[root@centos11 mysql]#  /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/lo                                             cal/mysql/data/
2020-04-03T10:49:28.944664Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults                                             _for_timestamp server option (see documentation for more details).
2020-04-03T10:49:31.571656Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-04-03T10:49:32.172069Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-04-03T10:49:32.424888Z 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: cd129a4b-7598-11ea-9d0c-00155dbcc30a.
2020-04-03T10:49:32.494296Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-04-03T10:49:32.495708Z 1 [Note] A temporary password is generated for root@localhost: 72pq+!sGbUpu

这个临时密码72pq+!sGbUpu不知道什么原因失效了

[root@centos11 mysql]# mysql -uroot -p
Enter password:
ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords.

解决办法:

1)、跳过权限

打开/etc/my.cnf 文件:

在[mysqld]标签下面加一行这个  

skip-grant-tables

2)、重启服务,一定要重启服务

service mysqld restart

3)、此时数据库不需要密码就可以登录

3)、用第三方工具登录数据库,

把密码过期限制去掉

4)、回去吧数据库跳过密码设置去掉

打开/etc/my.cnf 文件:

在[mysqld]标签下面注释掉  

#skip-grant-tables

重启

 

最后,修改密码就可以登录了~~~~~

TNND, 感觉踩过了所有的坑,不过最后成功了,还是蛮开心的,接着学习mysql高级吧。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值