当前位置:网站首页>MySQL安装
MySQL安装
2022-06-12 09:08:00 【较真的菜鸟】
安装包下载地址: https://downloads.mysql.com/archives/community/

查看是否已经有了安装的MySQL
检查系统是否安装mysql:
rpm -qa | grep mysql
如果有则强制卸载:
rpm -e --nodeps $(rpm -qa | grep mysql)
或者用
find / -name mysql
# 或者 whereis mysql 查询MySQL相关文件
# 发现后用rm -rf删除
MySQL 安装
上传至服务器并解压文件,必须将MySQL转义到/usr/local/mysql/目录下,否则启动会报错
tar -xvf mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.37-linux-glibc2.12-x86_64/* /usr/local/mysql/ # 修改MySQL目录,如果/usr/local/mysql/不存在就新建
建立用户和组
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
创建相关目录
mkdir -p /data/mysql
chown -R mysql:mysql /data # 给MySQL授权此目录权限
chown -R mysql:mysql /usr/local/mysql/
chmod 755 /data
``
## 配置环境变量
配置root用户环境变量
```sql
cat <<EOF>> /root/.bash_profile # <<EOF>>标识输入EOF后结束编辑
在文件可编辑状态输入
> export PATH=\$PATH:/usr/local/mysql/bin
> EOF
生效环境变量
source /root/.bash_profile
编译和初始化
./mysqld --initialize --user=mysql --datadir=/data/mysql --basedir=/usr/local/mysql
执行完成后把密码复制出来
配置my.cnf
在MySQL目录 cd /soft/mysql-5.7.37创建my.cnf
[mysqld]
user=mysql
datadir=/data/mysql
basedir=/usr/local/mysql
pid-file=/data/mysql/mysql.pid
port = 3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
symbolic-links=0
max_connections=400
innodb_file_per_table=1
lower_case_table_names=1
character_set_server=utf8mb4
socket=/data/mysql/mysql.sock
[mysqld]不能少,此是文件头
socket和pid-file最好指定并且给mysql用户赋权限
启动服务
/usr/local/mysql/support-files/mysql.server start

此表示启动成功
添加mysql 软连接并重启mysql服务
ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
service mysql restart
修改密码
登录
mysql -u root -p #提示输入密码后输入密码
set password for root@localhost = password('123456'); # 123456为修改后的密码
修改任何ip都可以访问
use mysql;
update user set user.Host='%' where user.User='root';
flush privileges;
安装过程中遇到的问题
- 一开始没有把MySQL安装目录设置到
/usr/local/mysql启动报错 - 没有设置pid文件启动报错
- 登录时没有mysql.sock文件报错
- 还有启动时报忽略
my.cnf文件,原因是my.cnf权限为777,需要修改为655才不会被忽略
以上几种都创建文件后,然后给mysql用户授权即可,通过chown -R mysql:mysql 文件路径
chmod 755 文件路径
边栏推荐
- Leetcode 336 palindrome pair (palindrome string + hash)
- 2022 low voltage electrician retraining question bank and online simulation examination
- Offer:[day 8 dynamic planning (simple)] --- > maximum profit of stock
- [character set 6] wide string and multi byte character conversion
- Diff prime pairs
- MFS explanation (IV) -- MFS management server installation and configuration
- Chapter 8 - two basic problems of data processing
- 软件测试基础知识分享,写点你不知道的
- Chapter VI - procedures with multiple segments
- Tool classes for extracting zip files
猜你喜欢

Notes used by mqtt (combined with source code)

Building a cluster: and replacing with error
软件测试需求分析方法有哪些,一起来看看吧

2022 simulated examination platform operation of high voltage electrician work license question bank

Technology cloud report: how will the industrial Internet rebuild the security boundary in 2022?

网页中加载二次元3D虚拟主播源码(1:项目介绍和源码)
![Sword finger offer:[day 9 dynamic planning (medium)] --- > maximum sum of continuous subarrays](/img/6b/6dcc86bfe0f48103ef8420b9996c1e.jpg)
Sword finger offer:[day 9 dynamic planning (medium)] --- > maximum sum of continuous subarrays

Use NVM to dynamically adjust the nodejs version to solve the problem that the project cannot be run and packaged because the node version is too high or too low

MySQL learning record - II. MySQL create table command

分库分表会带来读扩散问题?怎么解决?
随机推荐
Ceil, floor and round functions
Flink CheckPoint : Exceeded checkpoint tolerable failure threshold
机器学习笔记 - 循环神经网络备忘清单
Machine learning notes - circular neural network memo list
Solve the problem that when unity is opened, you will be prompted that the project has been opened, but you have not opened it before (it may be closed abnormally before)
清华大学数据挖掘笔记(一)
128. Plus longue séquence continue - table de hachage
2022 simulated examination platform operation of high voltage electrician work license question bank
Distributed task scheduling
Basic exercise decomposing prime factors
CodeCraft-22 and Codeforces Round #795 (Div. 2) 题解
数据库不知道哪里出问题
(十二)交互组件Selectable
2022 safety officer-c certificate special operation certificate examination question bank and simulation examination
Domain name mapping to specified IP
90%以上软件公司都会问的软件测试面试题赶紧来背吧
128. 最長連續序列-哈希錶
sql中的Exists用法
Tool classes for extracting zip files
Source code and scheme for target recognition, detection and 6D attitude estimation (the most advanced method and data set)