当前位置:网站首页>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 Chapter 4 Summary
- Enter a positive integer with no more than 5 digits, and output the last digit in reverse order
- CentOS installs redis multi master multi slave cluster
- Global and Chinese market for baked potato chips 2022-2028: Research Report on technology, participants, trends, market size and share
- Solution to the problem of compilation error due to repeated third-party package names
- 【Leetcode】76. Minimum covering substring
- Problems encountered in the application and development of Hongmeng and some roast
- 1. 两数之和(LeetCode题目)
- Small example of SSM project, detailed tutorial of SSM integration
- 开发者,微服务架构到底是什么?
猜你喜欢

Under the double reduction, the amount of online education has plummeted. Share 12 interesting uses of webrtc

String constant pool, class constant pool, and runtime constant pool

Some problems to be considered when designing technical implementation scheme

904. fruit baskets

瑞萨电子面向物联网应用推出完整的智能传感器解决方案

MySQL第六次作业-查询数据-多条件

哪些PHP开源作品值得关注

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

36 qtextedit control input multiline text

開發者,微服務架構到底是什麼?
随机推荐
【LeetCode】59. Spiral matrix II
String class intern() method and string constant pool
What is LSP
Basic string operations in C
Enter a positive integer with no more than 5 digits, and output the last digit in reverse order
cmake / set 命令
Using foreach to loop two-dimensional array
Express (I) - easy to get started
VS或Qt编译链接过程中出现“无法解析的外部符号”的原因:
SSH, SCP command appears permission denied, please try again solution
Detailed explanation of winsorflow quantum installation process
JS reverse | four libraries and one platform response data encryption
RDB持久化验证测试
Omni channel, multi scenario and cross platform, how does app analyze channel traffic with data
Global and Chinese market of cryogenic bulk tanks 2022-2028: Research Report on technology, participants, trends, market size and share
Small example of SSM project, detailed tutorial of SSM integration
118. Yanghui triangle
Global and Chinese market of amateur football helmets 2022-2028: Research Report on technology, participants, trends, market size and share
Procedure Call Standard
Based on Zeng Shen's explanation, the line segment tree is studied again one