我用mysql 社区版进行的安装,在linux centos 操作系统下, yum install 方式
系统默认安装时没有密码的,需要你及时设置,但是我操作多次后,并没有修改密码,启动和关闭多次以后就登录不上了。
只要重新安装授权表即可,注意指定data目录。
注意:mysql5.7 之后的初始化方式改变成了 mysqld --initizlize
所以对于使用者来说,对于各个版本之间的变化很重要,在百度搜索问题时,一定要注意版本的变化。

查看下原来的目录下的权限情况

 [root@fp-web-118 bin]# ll /var/lib/mysqltotal 110604-rw-rw---- 1 mysql mysql 56 Jan 30 20:14 auto.cnf-rw-rw---- 1 mysql mysql 12582912 Feb 1 20:44 ibdata1-rw-rw---- 1 mysql mysql 50331648 Feb 1 20:44 ib_logfile0-rw-rw---- 1 mysql mysql 50331648 Jan 30 20:14 ib_logfile1drwx------ 2 mysql mysql 4096 Jan 30 20:14 mysqlsrwxrwxrwx 1 mysql mysql 0 Feb 1 20:44 mysql.sockdrwx------ 2 root root 4096 Feb 1 20:38 performance_schema

重新安装

[root@fp-web-118 bin]# mysql_install_db --datadir=/var/lib/mysql

执行过程,关键部分我留下来做了翻译------Installing MySQL system tables...2022-02-01 20:38:29 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2022-02-01 20:38:29 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.2022-02-01 20:38:29 0 [Note] /usr/sbin/mysqld (mysqld 5.6.51) starting as process 75620 ...2022-02-01 20:38:29 75620 [Note] InnoDB: Using atomics to ref count buffer pool pages2022-02-01 20:38:29 75620 [Note] InnoDB: The InnoDB memory heap is disabled2022-02-01 20:38:29 75620 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins..... ##其他部分不必要信息我删除掉了,留下仅有的一些提示/usr/bin/mysqladmin -u root password 'jinzs'/usr/bin/mysqladmin -u root -h fp-web-118 password 'jinzs'  你可以运行 /usr/bin/mysql_secure_installation
他会给你一些选项去删除test数据库或者是匿名的用户,通过默认方式安装得时候cd /usr ; /usr/bin/mysqld_safe & ##你可以测试你的mysql,用这个脚本 mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl ##你可以测试你的mysql,用这个脚本 mysql-test-run.pl
WARNING: 默认是 /etc/my.cnf 会被读取,如果你要用别的配置文件,可以使用 --defaults-file参数设置

设置密码

 [root@fp-web-118 bin]# mysqladmin -u root -h fp-web-118 password 'jinzs'

登录


[root@fp-web-118 bin]# mysql -u root -h fp-web-118 -pjinzs
Warning: Using a password on the command line interface can be insecure.Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 6Server version: 5.6.51 MySQL Community Server (GPL)
Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>

我们看看 mysql_install_db得作用
1、当MySQL的系统库(mysql系统库)发生故障,需要初始化mysql数据库。
2、重新初始化授权表
3、在一台机器上安装mysql实例。

mysqladmin的相关命令:[root@fp-web-118 bin]# mysql_install_db --helpUsage: /usr/bin/mysql_install_db [OPTIONS]  --basedir=path       The path to the MySQL installation directory.  --builddir=path      If using --srcdir with out-of-directory builds, you                       will need to set this to the location of the build                       directory where built files reside.  --cross-bootstrap    For internal use.  Used when building the MySQL system                       tables on a different host than the target.  --datadir=path       The path to the MySQL data directory.                       If missing, the directory will be created, but its                       parent directory must already exist and be writable.  --defaults-extra-file=name                       Read this file after the global files are read.  --defaults-file=name Only read default options from the given file name.  --force              Causes mysql_install_db to run even if DNS does not                       work.  In that case, grant table entries that                       normally use hostnames will use IP addresses.  --help               Display this help and exit.                       --ldata=path         The path to the MySQL data directory. Same as --datadir.  --no-defaults        Don't read default options from any option file.  --keep-my-cnf        Don't try to create my.cnf based on template.                        Useful for systems with working, updated my.cnf.                       Deprecated, will be removed in future version.  --random-passwords   Create and set a random password for all root accounts                       and set the "password expired" flag,                       also remove the anonymous accounts.  --rpm                For internal use.  This option is used by RPM files                       during the MySQL installation process.                       Implies --keep-my-cnf option.  --skip-name-resolve  Use IP addresses rather than hostnames when creating                       grant table entries.  This option can be useful if                       your DNS does not work.  --srcdir=path        The path to the MySQL source directory.  This option                       uses the compiled binaries and support files within the                       source tree, useful for if you don't want to install                       MySQL yet and just want to create the system tables.  --user=user_name     The login username to use for running mysqld.  Files                       and directories created by mysqld will be owned by this                       user.  You must be root to use this option.  By default                       mysqld runs using your current login name and files and                       directories that it creates will be owned by you.Any other options are passed to the mysqld program.

mysql_install_db 一次修复密码的更多相关文章

  1. PHPRAP v1.0.6 发布,修复因php7.1版本遗弃mcrypt扩展造成安装失败的BUG

    PHPRAP,是一个PHP轻量级开源API接口文档管理系统,致力于减少前后端沟通成本,提高团队协作开发效率,打造PHP版的RAP. 更新记录 [修复]修复因php7.1版本遗弃mcrypt扩展造成安装 ...

  2. Centos搭建PHP5.3.8+Nginx1.0.9+Mysql5.5.17

    操作环境 操作系统:Mac Os Lion 虚拟主机:VMware Fusion 虚拟系统:Centos 5.5+ 操作用户:Root 实现目的:搭建LNMP环境. 安装依赖库和开发环境 #依赖库和开 ...

  3. mysql_8.0.12环境配置

    1. 官网下载mysql_8.0.12免安装包,解压到你存放的地方: 2. 配置环境变量(把bin的文件夹弄进系统path里面): 3. 在解压的根路径中,查看是否含有my.ini文件,没有就新建一个 ...

  4. MySQL从删库到跑路(一)——MySQL数据库简介

    作者:天山老妖S 链接:http://blog.51cto.com/9291927 一.MySQL简介 1.MySQL简介 MySQL是一个轻量级关系型数据库管理系统,由瑞典MySQL AB公司开发, ...

  5. iphone5s越狱之后必装

    一.iphone5s完美越狱之后必装插件一览表 由于iPhone5s配置了强大的64位的A7处理器,所以在iOS7完美越狱后,不少iPhone5s用户发现之前安装的大部分人们插件在越狱后难以兼容.但是 ...

  6. Centos6.8 Mysql5.6 安装配置教程

    MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,目前属于 Oracle 旗下产品.MySQL 最流行的关系型数据库管理系统,在 WEB 应用方面MySQL是最好的 RDBMS ...

  7. Jsp万能密码漏洞修复例子

    更多详细内容请查看:http://www.111cn.net/jsp/Java/58610.htm 如果网站出现这种“万能密码”漏洞该怎么办呢 'or'='or' 漏洞修复 方法有很多在这里介绍两种, ...

  8. Linux系统下root密码遗忘等系统故障的修复方法 - 运维总结

    IDC机房有一台centos系统的服务器,由于这台服务器的系统装了好长时间,且root密码中间更新过几次,后面去机房现场维护时,登陆密码遗忘了,悲催啊~没办法,只能开机进入“单用户模式”进行密码重置了 ...

  9. Centos 6.5 磁盘修复 破解删除root密码

    起因:由于存储设备故障.导致虚拟机断开.恢复后虚拟机无法启动,发现报磁盘损坏,需要运行fsck运行 问题解决思路: 1.虚拟机无法启动,所以需要进入系统进行修复 2.root密码是自动修改的.由于虚拟 ...

随机推荐

  1. LGP6240题解

    题解 我们可以发现,背包有结合律. 也就是先加入元素 \(a\) 再加入元素 \(b\) 和 \(c\),与先加入元素 \(a\) 后再与只有元素 \(b\) 和元素 \(c\) 的背包合并,得到的背 ...

  2. ArcGIS热点分析

    许多论文中一般会有热点分析图,ArcGIS中提供了热点分析的功能. 先看下描述:给定一组加权要素,使用 Getis-Ord Gi* 统计识别具有统计显著性的热点和冷点. 其实非常简单,今天博主就跟大家 ...

  3. 6月26日 Django 中间件

     前戏 我们在前面的课程中已经学会了给视图函数加装饰器来判断是用户是否登录,把没有登录的用户请求跳转到登录页面.我们通过给几个特定视图函数加装饰器实现了这个需求.但是以后添加的视图函数可能也需要加上装 ...

  4. OpenCV使用级联分类器实现人脸检测

    一.概述 案例:使用opencv级联分类器CascadeClassifier+其提供的特征数据实现人脸检测,检测到人脸后使用红框画出来. API介绍:detectMultiScale( InputAr ...

  5. _u32定义

    驱动开发的原则: 能用__u32就最好用它,或者用u_int32_t之类的也可以,但不要直接用unsigned int等默认的数据类型.目的是让别人明白,你这个变量占多大内存. 原因: 1.你不能确定 ...

  6. WebGPU 计算管线、计算着色器(通用计算)入门案例:2D 物理模拟

    目录 1. WebGL 2. WebGPU 2.1. 适配器(Adapter)和设备(Device) 2.2. 着色器(Shaders) 2.3. 管线(Pipeline) 2.4. 并行(Paral ...

  7. 内网渗透----域环境搭建(server 2012)

    先确定两台服务器相通 1.配置静态IP与DNS 2.配置域服务 点击服务器管理器-添加角色和功能-下一步-添加AD域服务: 3.提升为域控制器 安装完成后,可在旗帜处选择提升为域控制器 添加新林 添加 ...

  8. vs 2019 社区版 .net core 5.0 之 .net core ef 迁移问题方案

    问题一:Add-Migration 时出现 此类问题一般都是模型类主键标识问题增加KEY即可解决 报错: The entity type 'xxxx' requires a primary key t ...

  9. Flutter入门教程(一)Flutter简介

    这是Flutter系列第一篇文章,后续会持续更新Flutter相关知识,本篇就主要对于Flutter技术做一个简单的入门介绍 一.Flutter简介 Flutter是谷歌的移动UI框架,可以快速在iO ...

  10. synchronized已经不在臃肿了,放下对他的成见之初识轻量级锁

    前言 物竞天择,适者生存.JDK也在不断的优化中.关于JDK中synchronized锁内部也是不断的优化,前面我们分析了偏向锁用来解决初期问题,随着争抢的不断堆积轻量级锁营运而生. 关注我,一个不断 ...