当前位置: 首页 > article >正文

【MySQL】MySQL 在 Centos 7环境安装

目录

  • 1. 卸载不要的环境
  • 2. 检查系统安装包
  • 3. 卸载这些默认安装包
  • 4. 安装mysql
  • 5. 启动服务
  • 6. 查看启动服务
  • 7. 登陆
  • 8. 配置密码
  • 9. 配置my.cnf

1. 卸载不要的环境

[xl@VM-0-3-centos ~]$ ps ajx |grep mariadb # 先检查是否有mariadb存在
...
[xl@VM-0-3-centos ~]$ ps axj |grep mariadb # 停⽌完成

2. 检查系统安装包

[xl@VM-0-3-centos ~]$ rpm -qa | grep mariadb
or
[xl@VM-0-3-centos ~]$ rpm -qa | grep mysql

# 下⾯是打印出来的mysql的样例,
[root@bite-alicloud mysql]# rpm -qa | grep mysql
mysql-community-common-5.7.41-1.el7.x86_64
mysql-community-server-5.7.41-1.el7.x86_64
mysql57-community-release-el7-11.noarch
mysql-community-client-5.7.41-1.el7.x86_64
mysql-community-libs-5.7.41-1.el7.x86_64

3. 卸载这些默认安装包

[xl@VM-0-3-centos ~]$ rpm -qa | grep mysql | xargs yum remove
or
[xl@VM-0-3-centos ~]$ rpm -qa | grep mariadb | xargs yum -y remove

4. 安装mysql

一键安装:(安装在新建的xl用户下的mysql文件夹里)

curl -sLf https://gitee.com/lpsdz-ybhdsg-jk/some-convenient-scripts/raw/master/mysql_install.sh -o /tmp/mysql_install.sh && bash /tmp/mysql_install.sh

5. 启动服务

[xl@VM-0-3-centos 9.9]$ systemctl start mysqld.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: root
Password:
==== AUTHENTICATION COMPLETE ===

6. 查看启动服务

[xl@VM-0-3-centos 9.9]$ ps axj |grep mysqld
   1 23183 23182 23182 ? -1 Sl 27 0:00 /usr/sbin/mysqld --
daemonize --pid-file=/var/run/mysqld/mysqld.pid
13134 23243 23242 13134 pts/0 23242 S+ 1005 0:00 grep --color=auto
mysqld

7. 登陆

[root@bite-alicloud mysql]# vim /etc/my.cnf # 打开mysql配置⽂件
在[mysqld]最后⼀栏配置(不知道是什么,就放在配置⽂件最后) 加⼊: skip-grant-tables 选项,
并保存退出

[root@bite-alicloud mysql]# systemctl restart mysqld # 重启mysql服务
# 登陆成功
[root@bite-alicloud mysql]# mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.41 MySQL Community Server (GPL)
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>

8. 配置密码

#使⽤临时密码登录
[xl@VM-0-3-centos 9.9]$ mysql -uroot -p
Enter password:

9. 配置my.cnf

#配置⼀下my.conf,主要是数据库客⼾端和服务器的编码格式
[xl@VM-0-3-centos 9.9]$ cat /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysql]
#default-character-set=utf8 ,暂不设置,mysql有bug,汉字不回显
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
port=3306                    //重点加入
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

character-set-server=utf8          //重点加入
default-storage-engine=innodb       //重点加入
# 配置完毕,重启mysql即可

http://www.kler.cn/news/311586.html

相关文章:

  • Hive自定义函数——简单使用
  • C#广泛应用的简洁匿名函数Lambda 表达式
  • 基于Python的自然语言处理系列(12):使用TorchText和LSTM进行序列到序列(seq2seq)翻译
  • LVGL 控件之仪表盘(lv_meter)
  • Learn ComputeShader 15 Grass
  • 【JVM】垃圾回收
  • 派遣函数 - 缓冲区设备模拟文件读写
  • 服务器数据恢复—raid5阵列热备盘上线失败导致阵列崩溃的数据恢复案例
  • redis为什么不使用一致性hash
  • 向日葵好用吗?4款稳定的远程控制软件推荐。
  • 关于交叉编译移植到Debian开发板的一些随笔
  • gbase8s存储过程一些隐藏的错误写法
  • docker镜像源
  • info 命令:查看命令手册
  • 案例分析-Stream List 中取出值最大的前 5 个和最小的 5 个值
  • 动态内存
  • 7.Java高级编程 多线程
  • flutter Dio发送post请求
  • Linux: debug:内核log有乱码^@^@
  • Redis——分布式锁
  • JVM 虚拟机的编译器、类加载过程、类加载器有哪些?
  • Paragon NTFS for Mac和Tuxera NTFS for Mac,那么两种工具有什么区别呢?
  • python中的排序函数sorted
  • 波分技术基础 -- MS-OTN介绍
  • AIGC论文查重是什么?
  • 【Verilog学习日常】—牛客网刷题—Verilog快速入门—VL23
  • C++笔记21•C++11的新特性•
  • Springboot请求响应案例
  • Ruoyi Cloud K8s 部署
  • Golang | Leetcode Golang题解之第415题字符串相加