MySQL改了tables没用_Mysql8.0数据库修改密码/无法修改密码【改用"mysqld --console --skip-grant-tables --shared-memory"修改密码】...

本文参考了:https://www.pianshen.com/article/7287279782/

一、关闭SQL

第一种方法:

windows键+r,输入services.msc,点确定,如下所示

3f9c1435fbc43d634a0b83c50790bc04.png再找到MYSQL右键停止服务,

6f3b3251e646f1b504d7b88c31dbc930.png

第二种方法:

如下所示用管理员身份打开命令行

c7c08021aeeb7dd023a57273ccc85cb3.png

cmd命令行输入:net stop mysql; 服务停止中 -> 服务已停止,如下所示

b01c369b402f99be8577cbe09e6cd9c7.png

二、打开cmd界面,定位到mysql安装目录的bin文件下

也就是找到这个目录的里面的bin,里面放的是mysql.exe及mysqld.exe等,:

74a9bf736706b0f923953d29950967af.png

输入

cd C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin

(注:地址是你自己的安装目录地址)

三、启动MySQL服务的时候跳过权限表认证

很多博主是输入“mysqld --skip-grant-tables ”,但是最新的数据库版本这个命令已失效,会发现命令窗口仍然跳出下一行待输入指令。

应该输入:

mysqld --console --skip-grant-tables --shared-memory

生成界面如下,此时dos窗口不能运行,再另开一个cmd窗口操作第四步。【我之前一直以为这样的是错误的界面,然而还是太天真了,其实这就是可以了,然后直接另开一个cmd去绕过修改mysql的密码的了。所以如果是下图这种情况,就可以直接去第四步了。】

d3f9b9029c0807c1ed19c89a1d6788bf.png注意:有可能会出现下图的情况

663dd9da7258918de9317a56f9f9bef5.png也就是这个InnoDB: The InnoDB memory heap is disabled错误情况。

这个错误的解决方法,就是在你的my.ini【Linux系统是my.cnf文件】里面的[mysqld]下面加一行

4ec0f97d40e72198bbe7640d412579f6.png

指代存放的地址空间到E盘的MySQL Datafiles,如果直接重启的话,文件夹会有如下情况:

24f90f76c5379b3f7b91e3788a85c88b.png

如果还没有解决的话,就是找到你的存放数据库的data文件夹内,也就是根据你my.ini里面的datadir变量所指的路径我的是这个,如下图所示

3f0d7418f49c4e21e7fb3bd39105c833.png

删除掉下面三个文件:

254744f38a5103bcba104f69d7acda68.png>然后再重启mysql,基本上都能解决了。如果还不行,那我也没辙了,或者你可以下一下我待会上次的my.ini,是mysql5.5的,记得要改里面的basedir和datadir变量值就是了。

四、直接输入’mysql’免密登入数据库

输入 mysql,如果成功,显示如下界面,下一行的提示命令为mysql

8777b00022813be99d465f70fd596abe.png

五、输入’ use mysql '连接权限数据库

49df4ce2991ced2680635524cbaf35f5.png

六、输入’ show tables; '(分号注意)

c70bdce36bf7218bc0e48d67f709af73.png

显示图片如下,最下面有一个user,里面就有我们想要的信息。

在这里插入图片描述

七、注意这里的第一种情况对应八的第一种情况处理,第二种情况对应八的第二种情况处理【我个人是属于第一种情况。】

**第一种情况输入:select user,host,password from user; 查看user信息如下图所示

96d2bb764afc59d5a4df1ad02b1549bd.png

如果提示错误ERROR 1054 (42S22): Unknown column ‘password’ in ‘field list’,就看第二种情况

第二种情况输入:select user,host from user; 查看user信息b42a582b3921827628e8ececde2786e2.png

八、修改密码

第一种情况(七中的第一种情况请按照这个来)

update user set password=password("123456") where user="root";

如下图所示:

6876810e3dffc7324afd0975f6b4fa18.png如果报错,请看情况二:ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘(‘123’) where user=‘root’ and host=‘localhost’’ at line 1

第二种情况(七中的第二种情况请按照这个来)

update mysql.user set authentication_string="123456" where user="root";

九、刷新权限。输入:flush privileges;(必做)

e808bc9ac367215a985aab84d57f8afd.png

最后quit数据库,还会很萌地跟你say bye。

附加问题的解决方法:

ERROR 1130 (HY000): Host ‘127.0.0.1’ is not allowed to connect to this MySQL server

解决方法:注释掉my.ini中的skip_name_resolve

然后还有就是:查看数据库代码:

show databases;

通过命令行进入数据库代码:

mysql -u root -p

//回车,然后输入密码就可以了

写到现在这个博客,真的感慨万分,因为这次的东西是第二次遇见了,上一次也花了好长时间解决了,但是当时是好了伤疤忘了疼,没有写博客。而这次真的是十分地后悔,所以附上一个相对来说比较完整的解决方法吧,希望能够帮到大家!

再次声明:这篇博文参考了:https://www.pianshen.com/article/7287279782/

最后:

这是我my.ini文件的内容:

# Example MySQL config file for small systems.

#

# This is for a system with little memory (<= 64M) where MySQL is only used

# from time to time and it's important that the mysqld daemon

# doesn't use much resources.

#

# MySQL programs look for option files in a set of

# locations which depend on the deployment platform.

# You can copy this option file to one of those

# locations. For information about these locations, see:

# http://dev.mysql.com/doc/mysql/en/option-files.html

#

# In this file, you can use all long options that a program supports.

# If you want to know which options a program supports, run the program

# with the "--help" option.

# The following options will be passed to all MySQL clients

[client]

#password= your_password

port= 3306

socket= /tmp/mysql.sock

# Here follows entries for some specific programs

# The MySQL server

[mysqld]

port= 3306

socket= /tmp/mysql.sock

skip-external-locking

key_buffer_size = 16K

max_allowed_packet = 1M

table_open_cache = 4

sort_buffer_size = 64K

read_buffer_size = 256K

read_rnd_buffer_size = 256K

net_buffer_length = 2K

thread_stack = 128K

# Don't listen on a TCP/IP port at all. This can be a security enhancement,

# if all processes that need to connect to mysqld run on the same host.

# All interaction with mysqld must be made via Unix sockets or named pipes.

# Note that using this option without enabling named pipes on Windows

# (using the "enable-named-pipe" option) will render mysqld useless!

#

#skip-networking

server-id= 1

# Uncomment the following if you want to log updates

#log-bin=mysql-bin

# binary logging format - mixed recommended

#binlog_format=mixed

# Causes updates to non-transactional engines using statement format to be

# written directly to binary log. Before using this option make sure that

# there are no dependencies between transactional and non-transactional

# tables such as in the statement INSERT INTO t_myisam SELECT * FROM

# t_innodb; otherwise, slaves may diverge from the master.

#binlog_direct_non_transactional_updates=TRUE

# Uncomment the following if you are using InnoDB tables

#innodb_data_home_dir = C:\\mysql\\data\\

#innodb_data_file_path = ibdata1:10M:autoextend

#innodb_log_group_home_dir = C:\\mysql\\data\\

# You can set .._buffer_pool_size up to 50 - 80 %

# of RAM but beware of setting memory usage too high

#innodb_buffer_pool_size = 16M

#innodb_additional_mem_pool_size = 2M

# Set .._log_file_size to 25 % of buffer pool size

#innodb_log_file_size = 5M

#innodb_log_buffer_size = 8M

#innodb_flush_log_at_trx_commit = 1

#innodb_lock_wait_timeout = 50

[mysqldump]

quick

max_allowed_packet = 16M

[mysql]

no-auto-rehash

# Remove the next comment character if you are not familiar with SQL

#safe-updates

[myisamchk]

key_buffer_size = 8M

sort_buffer_size = 8M

[mysqlhotcopy]

interactive-timeout

[mysqld]

innodb_use_sys_malloc =0

tmpdir = "E:\\MySQL Datafiles"

#设置basedir指向mysql的安装路径

federated

skip-external-locking

#skip-name-resolve

basedir=C:\Program Files (x86)\MySQL\MySQL Server 5.5

datadir=C:\ProgramData\MySQL\MySQL Server 5.5\data

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值