前言
如今红帽Linux上默认是没有yum源的mysql
yum软件仓库里面只有MariaDB的安装包因此咱们须要本身先配置yum源sql
实验准备(如下操做在VMware中进行)
一台Linux主机 (我这里用的是RHEL7.4)
已经联网
不要挂载yum镜像
数据库
一、配置yum源
下载yum源(我这里已经找好了)this
wget 'https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm'
yum源下载连接:MySQLspa
安装yum源code
rpm -Uvh mysql57-community-release-el7-11.noarch.rpm
查看有哪些版本的mysqlorm
yum repolist all | grep mysql
二、安装
yum install -y mysql-community-server
三、启动mysql
注意启动的时候是mysqld而不是mysqlserver
systemctl start mysqld
查看状态教程
systemctl status mysqld
四、登陆数据库,修改数据库密码
找到密码: 红框的地方就是密码get
[root@localhost ~]# grep 'temporary password' /var/log/mysqld.log 2020-12-18T15:15:55.572640Z 1 [Note] A temporary password is generated for root@localhost: 9sX3oDXGti)P 密码:9sX3oDXGti)P
五、登陆MySQL
[root@localhost ~]# mysql -uroot -p'9sX3oDXGti)P' mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.32 Copyright (c) 2000, 2020, 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>show databases; ---这里会报错,须要从新修改密码 ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
修改密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'XXGC.lab123'; Query OK, 0 rows affected (0.01 sec) ---表示修改为功
刷新
mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
退出
mysql> exit
六、使用新密码登陆数据库
[root@localhost ~]# mysql -uroot -p'XXGC.lab123' mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.32 MySQL Community Server (GPL) Copyright (c) 2000, 2020, 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> show databses; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec) mysql>
以上就是在RHEL7.4中配置MySQL的教程