当前位置:网站首页>Linux下安装Mysql【详细】
Linux下安装Mysql【详细】
2022-06-26 09:45:00 【YLi_Jing】
1、下载安装包(以Mysql5.7为例)
下载方式一https://dev.mysql.com/downloads/mysql/5.7.html

下载方式二:
wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz
2、进行解压缩
tar -zxvf mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz
解压后的文件夹名字太长,可以进行重命名
mv mysql-5.7.36-linux-glibc2.12-x86_64 mysql-5.7.36
3、一些相关配置
进入mysq-5.7.36目录下,新建一个data文件夹
mkdir data
赋予权限:
chmod -R 777 data
创建用户、组信息
groupadd mysql
useradd -g mysql mysql
修改etc/my.cnf文件,以下是全部内容,注意路径改成你自己的安装路径即可
[mysqld]
bind-address=0.0.0.0
port=3306
user=mysql
basedir=/qijingjing/resource/mysql/mysql-5.7.36
datadir=/qijingjing/resource/mysql/mysql-5.7.36/data
socket=/tmp/mysql.sock
log-error=/qijingjing/resource/mysql/mysql-5.7.36/data/mysql.err
pid-file=/qijingjing/resource/mysql/mysql-5.7.36/data/mysql.pid
character_set_server=utf8mb4
symbolic-links=0
explicit_defaults_for_timestamp=true
进入mysql5.7.36的bin目录下面执行以下命令(注意:路径修改你自己的)
./mysqld --initialize --user=mysql --datadir=/qijingjing/resource/mysql/mysql-5.7.36/data/ --basedir=/qijingjing/resource/mysql/mysql-5.7.36/
对mysql默认生成密码进行查看(等会登陆需要用)
cat /qijingjing/resource/mysql/mysql-5.7.36/data/mysql.err

添加软连接->为了我们在任意目录都可以启动mysql
ln -s /qijingjing/resource/mysql/mysql-5.7.36/support-files/mysql.server /etc/init.d/mysql
ln -s /qijingjing/resource/mysql/mysql-5.7.36/bin/mysql /usr/bin/mysql
service mysql restart
登陆mysql
启动
service mysql start
登陆
mysql -uroot -p
回车后输入密码即可登陆:
修改密码
set password=password('你需要设置的密码');
flush privileges;
修改访问权限
use mysql;
update user set Host='%' where User='root';
flush privileges;
4、外部访问
外网访问需要将防火墙的对应3306端口放行,执行以下操作即可
firewall-cmd --zone=public --add-port=3306/tcp --permanent
systemctl restart firewalld.service
如果是云服务器的话,要在安全组配置放行:

到这里,我们就可以使用SQLyog或者Navicat工具进行连接使用了。
边栏推荐
- Constraintlayout control uses full Raiders
- Enter a positive integer with no more than 5 digits, and output the last digit in reverse order
- When will JVM garbage collection enter the older generation
- MySQL 9th job - connection Query & sub query
- Problems encountered in the application and development of Hongmeng and some roast
- How to start the learning journey of webrtc native cross platform development?
- MySQL第六章总结
- C中字符串基本操作
- How to change the QR code material color of wechat applet
- SQL Server 基础介绍整理
猜你喜欢

904. fruit baskets

How to change the QR code material color of wechat applet

Enter a positive integer with no more than 5 digits, and output the last digit in reverse order

Write data to local file

量化投资学习——经典书籍介绍

MySQL第八次作业

DBSCAN

Allocation of heap memory when creating objects

Call API interface to generate QR code of wechat applet with different colors

904. 水果成篮
随机推荐
Standard implementation of streaming layout: a guide to flexboxlayout
US President signs community safety act to deal with gun issue
See how I store integer data in the map < string, string > set
Progressive Web 应用程序PWA是应用程序开发的未来
1. sum of two numbers (leetcode topic)
How do technicians send notifications?
量化投资学习——经典书籍介绍
Enter a positive integer with no more than 5 digits, and output the last digit in reverse order
118. 杨辉三角
搜索引擎高级搜索方法记录
Global and Chinese market of electronic pet door 2022-2028: Research Report on technology, participants, trends, market size and share
六月集训(第26天) —— 并查集
CentOS安装Redis多主多从集群
MySQL job 11 - application de la vue
Renesas electronics launched a complete intelligent sensor solution for Internet of things applications
Establishment of smart dialogue platform for wechat official account
Dialog centered
Hcia-dhcp experiment
开发者,微服务架构到底是什么?
LSP 是什么