部署mysql

mysql官方地址:

https://dev.mysql.com/downloads/mysql/

 

一. 部署数据库mysql5.6
cd /opt
wget https://cdn.mysql.com/archives/mysql-5.6/MySQL-5.6.49-1.el7.x86_64.rpm-bundle.tar
mkdir mysql5.6
tar -xf MySQL-5.6.49-1.el7.x86_64.rpm-bundle.tar -C mysql5.6
cd mysql5.6
yum localinstall ./*


1.安装完成后,检查mysql配置文件,修改一下(不修改启动报错)
cat /etc/my.cnf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 修改 mysqld_safe里面的内容,原本是mariadb,换成mysql
 
 
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
 
[mysqld_safe]
log-error=/var/log/mysql/mysql.log
pid-file=/var/run/mysql/mysql.pid
 
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

  


1)mysql安装后会出现一个默认随机密码
cat ~/.mysql_secret
# The random password set for the root user at Thu Jan 9 05:33:17 2025 (local time): ozYc0qv5OFIBzcP3


2.启动mysql
systemctl start mysql
systemctl enable mysql

 

3.修改root密码

方法一:(必须执行这一步,以后修改密码可用方法二)
mysqladmin -uroot -pozYc0qv5OFIBzcP3 password 123456

方法二:(进入mysql修改)

1
2
3
4
5
6
7
8
# 进入mysql
mysql -uroot -p
 
#修改密码
update mysql.user set password=password('123456') where user='root';
 
# 刷新生效
flush privileges;

  

  

 

posted @   铿锵有力自信且坚定  阅读(14)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
· 25岁的心里话
点击右上角即可分享
微信分享提示