win10下虚拟机中的centOS7如何安装mysql

第一步:查看当前系统是否自带MySQL数据库

[root@MySqlServer ~]# rpm -qa | grep mysql
mysql-libs-5.1.66-2.el6_3.i686
[root@MySqlServer ~]#

说明:执行 rpm -qa | grep mysql 命令来查看当然系统是否自带有MySQL数据库,若有,则会显示MySQL软件名称。

第二步:卸载自带的MySQL数据库

[root@MySqlServer ~]# rpm -e --nodeps mysql-libs-5.1.66-2.el6_3.i686 [root@MySqlServer ~]#
说明:命令 rpm -e --nodeps [要卸载的软件名] 用于卸载软件。

第三步:安装从网上下载文件的wget命令

[root@master ~]# yum -y install wget

wget 是一个从网络上自动下载文件的自由工具

第四步:下载mysql的repo源

[root@master ~]# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm 

如果下载成功,它会在/root目录下有一个mysql-community-release-el7-5.noarch.rpm文件

第五步:将当前目录转到 /root之下

第六步:安装mysql-community-release-el7-5.noarch.rpm包

[root@master ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm

第七步:查看下,意思是看安装mysql有几个源

[root@master ~]# ls -1 /etc/yum.repos.d/mysql-community*
/etc/yum.repos.d/mysql-community.repo
/etc/yum.repos.d/mysql-community-source.repo

会获得两个mysql的yum repo源:/etc/yum.repos.d/mysql-community.repo,/etc/yum.repos.d/mysql-community-source.repo。

第八步:安装mysql

[root@master ~]# yum install mysql-server

第九步:

6)启动mysql服务

[root@MySqlServer mysql]# service mysql start
Starting MySQL.                                            [  OK  ]
[root@MySqlServer mysql]#

7)连接数据库

[root@MySqlServer mysql]# mysql -uroot -p
Enter password:

结果是密码错误,需要重置密码

 

[root@VM_0_11_centos /]# grep 'temporary password' /var/log/mysqld.log 

2018-08-10T09:50:14.984060Z 1 [Note] A temporary password is generated for root@localhost: jK_e>o6siRFg

[root@VM_0_11_centos /]# mysql -uroot -p

Enter password: 输入上面查询到的密码【jK_e>o6siRFg】

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.7.23

 

Copyright (c) 2000, 2018, 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> show databases;

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

mysql> set password for root@localhost = password('123456');

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

 

mysql> set password for root@localhost = password('Root@123456');

Query OK, 0 rows affected, 1 warning (0.00 sec)

 

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| sys                |

+--------------------+

4 rows in set (0.00 sec)

mysql> 

完成!

启动mysql:

              service mysqld start

停止mysql:

            service mysqld stop

 

查看mysql文件安装路径

由于软件安装的地方不止一个地方,所有先说查看文件安装的所有路径(地址)。

这里以mysql为例。比如说我安装了mysql,但是不知道文件都安装在哪些地方、放在哪些文件夹里,可以用下面的命令查看所有的文件路径 在终端输入:

whereis mysql

回车,如果你安装好了mysql,就会显示文件安装的地址,例如我的显示(安装地址可能会不同)

[root@localhost ~]# whereis mysql mysql: /usr/bin/mysql /usr/lib/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz

二、查询运行文件所在路径(文件夹地址)

如果你只要查询文件的运行文件所在地址,直接用下面的命令就可以了(还是以mysql为例):

which mysql

终端显示:

[root@localhost ~]# which mysql

/usr/bin/mysql

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

庭博

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值