记录一下linux下载mysql中的过程和困难

作为一个小白,用linux下载mysql,摸索了好几天,删了重下反反复复,好几天了,今天终于安装完成了,记录一下过程。

安装linux有三种方法,之前试过用rpm安装,一直安装不上去,所以这里讲的是安装ga的压缩包。装的是(mysql-5.6.44-linux-glibc2.12-x86_64.tar.gz)。


目录

一、卸载原来的mysql

 二、安装

其中遇到的困难(与视频中的不同的地方):

1.上传软件包

2.初始化数据库

3.设置远程访问和开机自启动


一、卸载原来的mysql

https://www.jianshu.com/p/0ee875dfcec9 这篇从Linux卸载mysql开始操作。

 二、安装

参考https://www.bilibili.com/video/BV1mJ411z7GZ?p=6 b站的视频,这个比较详细。


其中遇到的困难(与视频中的不同的地方):

1.上传软件包

我是直接在linux图形界面用火狐浏览器登录官网,然后下载

然后弹出界面,选保存界面

再打开终端:

以root的身份登录(输入 su root 然后回车,再输入登录密码,再回车。注意:密码是不会显示出来的)

再进入到下载的目录里面,即(注意这里的wenjiamei是自己的用户名)

cd /home/wenjiamei/下载

 可以到图形界面查看:

 

 

然后(一个小技巧:Tab可以补全文件名称,比如你输入tar -zxf my然后再按Tab键可以补全文件名称)

 

 其余操作和视频里的一样。

2.初始化数据库

1.出现了这样的错误:

 解决方法:输入

yum install -y perl-Module-Install

 再输入命令即可:

 

2. 输入service mysql start 后出现错误

解决方法:参考https://blog.csdn.net/weixin_43495429/article/details/90552032中的启动mysql

我试了第一种给予权限的解决方法,但是并没有用,后面我又试了第二种用命令“ps -ef|grep mysqld”查看是否有mysqld进程的解决方法,后面居然可以了!

 后面就和视频里一模一样啦。。。还有问题的话看看视频里的评论或者上面的链接其他解决方法哦~

3.设置远程访问和开机自启动

参考centos7装mysql(亲测可用)_我不当大哥好多年了的博客-CSDN博客中的第六、七、八步,我参考链接写的如下:

mysql> exit;
Bye
[root@localhost mysql]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
success
[root@localhost mysql]# firewall-cmd --reload
success
[root@localhost mysql]# service mysql start
Starting MySQL SUCCESS! 
[root@localhost mysql]# 220216 11:09:08 mysqld_safe A mysqld process already exists
firewall-cmd --zone=publ^C
[root@localhost mysql]# bin/mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
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> bin/mysql -uroot -p
    -> grant all privileges on *.* to root@'%' identified by 'root';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'bin/mysql -uroot -p
grant all privileges on *.* to root@'%' identified by 'root'' at line 1
mysql> grant all privileges on *.* to root@'%' identified by 'root';
Query OK, 0 rows affected (0.04 sec)

mysql> grant all privileges on *.* to root@'%' identified by '123';
Query OK, 0 rows affected (0.03 sec)

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

mysql> exit;
Bye
[root@localhost mysql]# chkonfig --add mysql
bash: chkonfig: 未找到命令...
[root@localhost mysql]# chkconfig --add mysql
[root@localhost mysql]# chkconfig mysqlon
[root@localhost mysql]# chkconfig mysql on
[root@localhost mysql]# vim /etc/profile
[root@localhost mysql]# source /etc/profile
[root@localhost mysql]# mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@localhost mysql]# service mysql status
 SUCCESS! MySQL running (1434)
[root@localhost mysql]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
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的命令:mysql -u root -p 密码:123

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值