当前位置:网站首页>Linux下安裝Mysql【詳細】
Linux下安裝Mysql【詳細】
2022-06-26 10:34: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工具進行連接使用了。
边栏推荐
- MySQL第十二次作业-存储过程的应用
- 工程数学概率论统计简明教程第二版复习大纲
- 【無標題】
- Jar version conflict resolution
- Flutter与原生通信(上)
- Use of exec series functions (EXECL, execlp, execle, execv, execvp)
- Problems encountered in the application and development of Hongmeng and some roast
- 小笔记-简单但够用系列_KVM快速入门
- [binary search] 4 Find the median of two positive arrays
- 【在线仿真】Arduino UNO PWM 控制直流电机转速
猜你喜欢

AdaptiveAvgPool2D 不支持 onnx 导出,自定义一个类代替 AdaptiveAvgPool2D

Use of exec series functions (EXECL, execlp, execle, execv, execvp)

Developers, what is the microservice architecture?

904. fruit baskets

MySQL第十一作業-視圖的應用

基础-MySQL

Write data to local file

MySQL 13th job - transaction management

方法区里面有什么——class文件、class文件常量池、运行时常量池

Basic string operations in C
随机推荐
Global and Chinese markets in hair conditioner 2022-2028: Research Report on technology, participants, trends, market size and share
挖财商学院证券开户安全嘛?
字符串常量池、class常量池和运行时常量池
Procedure Call Standard
MySQL 11th job - view application
Establishment of smart dialogue platform for wechat official account
小笔记-简单但够用系列_KVM快速入门
MySQL第十一作業-視圖的應用
MySQL Chapter 4 Summary
二叉树常见面试题
String constant pool, class constant pool, and runtime constant pool
Constraintlayout control uses full Raiders
[untitled]
【Leetcode】76. 最小覆盖子串
MySQL 12th job - Application of stored procedure
【在线仿真】Arduino UNO PWM 控制直流电机转速
echo $?
Function run time
How to change the QR code material color of wechat applet
RDB持久化验证测试