在Linux上快速安装mysql

在Linux上快速安装mysql

1.下载

1.使用yum下载mysql的rpm包,首先需要 安装带有可用的mysql5系列社区版资源的rpm包

rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

2.列出可用mysql版本

yum repolist enabled | grep "mysql.*-community.*"

2.安装

安装mysql

yum -y install mysql-community-server

设置允许开机自启动

systemctl enable mysqld

开启mysql服务,关闭mysql服务,查看状态

systemctl start mysql
systemctl stop mysql
systemctl status mysql

3.设置账号密码

首先,直接终端输入mysql,会看到登录成功

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.6.51 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, 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>

输入你需要的账号密码

mysqladmin -u root password root

使用账号密码登录

mysql -u root -p

如果忘记密码,需要去配置文件中设置免密码登录

配置文件在/etc/my.conf

直接在[mysqld]下加一句

skip-grant-tables

esc, :wq保存退出,重启mysql

这个时候直接在终端输入mysql就可以登录成功了

重新设置密码后记得回到配置文件中删除该段,再重启

就可以使用密码登录了。

4.远程连接

首先需要授权

登录mysql

输入脚本

grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
flush privileges;

尝试使用navicat远程连接mysql

如果无法连接,查看3306端口是否开启

netstat -an | grep 3306

如果没有开启3306端口,开启

firewall-cmd --zone=public --add-port=3306/tcp --permanent

重启防火墙

 firewall-cmd --reload

查看是否监听端口

netstat -nalp|grep 3306
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值