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

Mysql-安装(Linux)

1、下载mysql

切换到/opt/app目录下,执行如下命令,下载mysql 5.7.38版本。

[root@ywxtdb app]# wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz

解压安装包

[root@ywxtdb app]# tar -zxvf mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz

2、创建用户、组

2.1 检查组是否存在

[root@ywxtdb app]# groups mysql groups: mysql: no such user

2.2 创建用户、关联组

[root@ywxtdb app]# groupadd mysql && useradd -r -g mysql mysql

2.3 创建工作空间

[root@ywxtdb app]# mkdir -p /data/mysql

赋权

[root@ywxtdb app]# chown mysql:mysql -R /data/mysql

3、修改配置文件

[root@ywxtdb app]# vim /etc/my.cnf

主要修改datadir

[mysqld] user=mysql datadir=/data/mysql socket=/data/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=/data/mysql/mysql.err pid-file=/data/mysql/mysql.pid [client] port=3306 socket=/data/mysql/mysql.sock # # include all files from the config directory # !includedir /etc/my.cnf.d

4、安装

4.1 移动安装包

将解压好的安装包移动到/usr/local/下,然后修改安装包名称为mysql

[root@ywxtdb local]# mkdir -p /usr/local/mysql [root@ywxtdb local]# cp -r /opt/app/mysql-5.7.38-linux-glibc2.12-x86_64/* /usr/local/mysql

4.2 初始化

[root@ywxtdb local]# cd /usr/local/mysql/bin/ [root@ywxtdb local]# ./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql --initialize

【如需】如果初始化出错,可以重新配置后再行初始化

[root@ywxtdb bin]# rm -rf /data/mysql/*

初始化

[root@ywxtdb local]# ./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql --initialize

4.3 查看初始化密码

最后的初始化密码 root@localhost: hicdf.s1It%j BED+8i(X5)mf -vc4H_woi!+6

[root@ywxtdb bin]# ./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql --initialize 2022-09-30T05:47:13.722877Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2022-09-30T05:47:14.169001Z 0 [Warning] InnoDB: New log files created, LSN=45790 2022-09-30T05:47:14.253178Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2022-09-30T05:47:14.315392Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 55d33b5f-4083-11ed-83cb-000c29ad1e70. 2022-09-30T05:47:14.359460Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2022-09-30T05:47:14.602832Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher. 2022-09-30T05:47:14.602861Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher. 2022-09-30T05:47:14.604186Z 0 [Warning] CA certificate ca.pem is self signed. 2022-09-30T05:47:14.687867Z 1 [Note] A temporary password is generated for root@localhost: hicdf.s1It%j adh;w.=s>1lV BED+8i(X5)mf

4.4 启动mysql

添加服务启动

[root@ywxtdb bin]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

启动

[root@ywxtdb mysql]# service mysql start Starting MySQL. SUCCESS!

4.5 修改密码

1、开启免密登录

修改my.cnf文件

[root@ywxtdb mysql]# vim /etc/my.cnf

在mysqld模块下面添加 skip-grant-tables

uploading.4e448015.gif

转存失败重新上传取消

2、重启mysql

[root@ywxtdb mysql]# service mysql restart Shutting down MySQL.. SUCCESS! Starting MySQL. SUCCESS!

3、登录mysql

上面开通免密后,可以直接Enter进入

[root@node1 bin] cd /usr/local/mysql/bin [root@node1 bin] ./mysql -u root -p

4、修改密码

use mysql; ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root'; flush privileges;

5、修改远程连接

update user t set t.host = '%' where t.user = 'root'; flush privileges;

http://www.lryc.cn/news/405931.html

相关文章:

  • 如何查看日志
  • python实现责任链模式
  • Prometheus监控ZooKeeper
  • vuepress搭建个人文档
  • 面试题 17.14.最小K个数
  • C++实现LRU缓存(新手入门详解)
  • 汇昌联信数字做拼多多运营实力好吗?
  • 【云原生】Prometheus 服务自动发现使用详解
  • (十九)原生js案例之h5地里位置信息与高德地图的初使用
  • 三、基础语法2(30小时精通C++和外挂实战)
  • gitee设置ssh公钥密码频繁密码验证
  • BGP选路之Next Hop
  • 牛客14666(优先屏障) + 牛客14847(Masha与老鼠)
  • Git下载与安装
  • 创建vue2/vue3项目
  • IOS七层模型对应的网络协议和物理设备
  • 论文复现:Predictive Control of Networked Multiagent Systems via Cloud Computing
  • JSON 文件存储
  • python——pynput
  • [用AI日进斗金系列]用码上飞在企微接单开发一个项目管理系统!
  • 《JavaEE篇》--多线程(2)
  • 防爆智能手机如何助力电气行业保驾护航?
  • 24.7.24数组|那几个课后得做的题
  • 03Spring底层架构核心概念解析
  • Vue学习---vue 防抖处理函数,是处理什么场景
  • 力扣爆刷第166天之TOP100五连刷96-100(单词拆分、回溯、旋转数组)
  • 2024在线PHP加密网站源码
  • 网络驱动移植(RTL8189)
  • go语言中map学习
  • 【C#】| 与 及其相关例子