21 mysql绿色安装版

2024/8/5

MySQL绿色安装版

复制代码
#清空/etc目录下的my.conf
 ls -l /etc/my.cnf
rm -rf /etc/my.cnf
 yum -y remove mariadb
find / -name "*mysql*" -exec rm -rf  {} \;
将MySQL压缩包拉拽到机器里
 tar -xvf mysql-8.0.33-linux-glibc2.12-x86_64.tar
 tar -xf mysql-8.0.33-linux-glibc2.12-x86_64.tar.xz
cd mysql-8.0.33-linux-glibc2.12-x86_64
ls -l

复制执行文件到/etc/local/mysql

复制代码
[root@mysql ~]# cp -r mysql-8.0.33-linux-glibc2.12-x86_64 /usr/local/mysql/

查看是否存在用户mysql

复制代码
[root@mysql ~]# id mysql
uid=27(mysql) gid=27(mysql) 组=27(mysql)
[root@mysql ~]# usradd -r -s /sbin/nologin mysql  //没有的话添加用户

在/usr/local/mysql下创建mysql-files目录

复制代码
[root@mysql ~]# mkdir /usr/local/mysql/mysql-files

添加属组,权限

复制代码
[root@mysql ~]# chown mysql:mysql /usr/local/mysql/mysql-files/
[root@mysql ~]# chmod 750 /usr/local/mysql/mysql-files/
[root@mysql ~]# ll /usr/local/mysql/
drwxr-x---.  2 mysql mysql      6 8月   5 09:56 mysql-files

添加mysql到系统中去

复制代码
[root@mysql ~]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/
2024-08-05T02:02:14.512638Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.33) initializing of server in progress as process 3122
2024-08-05T02:02:14.521764Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-08-05T02:02:15.223070Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2024-08-05T02:02:16.872935Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: zok*m6cVpInL   //下面要用mysql密码

查看是否成功

复制代码
[root@mysql ~]# cd /usr/local/mysql/
[root@mysql mysql]# ls
bin   docs     lib      man          README  support-files
data  include  LICENSE  mysql-files  share
​
复制代码
[root@mysql mysql]# 把mysql.server文件放到/etc/init.d/目录下
[root@mysql mysql]# 便于启动
[root@mysql mysql]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql8
 查看并添加权限
 chown -R mysql:mysql /usr/local/mysql/data
 chmod -R 755 /usr/local/mysql/data

启动成功

复制代码
[root@mysql mysql]# service mysql8 start
Starting MySQL SUCCESS! 
[root@mysql mysql]# service mysql8 restart
 ERROR! MySQL server PID file could not be found!
Starting MySQL.. SUCCESS!

进入MySQL

复制代码
[root@mysql ~]# /usr/local/mysql/bin/mysql -uroot -p
Enter password:   //密码
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@mysql ~]# /usr/local/mysql/bin/mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.33
​
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> 
​
相关推荐
纤瘦的鲸鱼17 小时前
MySQL慢查询
android·adb
Anthony_23117 小时前
MySQL的常用命令
运维·数据库·mysql·adb·docker
fatiaozhang952717 小时前
中国移动云电脑一体机-创维LB2004_瑞芯微RK3566_2G+32G_开启ADB ROOT安卓固件-方法3
android·xml·adb·电脑·电视盒子·刷机固件
独行soc1 天前
2025年渗透测试面试题总结-60(题目+回答)
java·python·安全·web安全·adb·面试·渗透测试
·云扬·1 天前
MySQL 日志全解析:Binlog/Redo/Undo 等 5 类关键日志的配置、作用与最佳实践
android·mysql·adb
飞龙AI2 天前
adb devices 显示为空?USB Composite Device 异常问题
adb
TeleostNaCl3 天前
如何安装 Google 通用的驱动以便使用 ADB 和 Fastboot 调试(Bootloader)设备
android·经验分享·adb·android studio·android-studio·android runtime
练小杰4 天前
【Mysql-installer-community-8.0.26.0】Mysql 社区版(8.0.26.0) 在Window 系统的默认安装配置
数据库·sql·mysql·adb·配置文件·mysql安装·关系型数据库
袁美丽..4 天前
Android studio的adb和终端的adb互相抢占端口
android·adb·android studio