MySQL常见问题的解决方法

目录

cmd没有管理员权限

没有my.ini这个文件

ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO)

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

其他常见问题


cmd没有管理员权限

cmd一定要用管理员权限打开。

限麻烦可以按win键,搜cmd。打开它所在的文件位置。把cmd的快捷方式拖到桌面,然后右键--属性--高级 设置下就行。

没有my.ini这个文件

很多问题都是因为没这个文件导致的,在使用MySQL前请自行检查一次。

在你的C:\Program Files\MySQL\MySQL Server 8.0(即你的MySQL的安装目录下)应该有一个my.ini文件,没有的话要自己添上。也可以复制下面这段然后自己新建一个ini粘贴进去。

别忘了根据你自己的文件路径改basedir和datadir。

# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
[client]
default-character-set = utf8
[mysql]
default-character-set = utf8
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8
init_connect='SET NAMES utf8'
# 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
# These are commonly set, remove the # and set as required.
basedir = C:\Program Files\MySQL\MySQL Server 8.0
datadir = C:\Program Files\MySQL\MySQL Server 8.0\data
port = 3306
# server_id = .....
# 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 = 16M
read_rnd_buffer_size = 16M 
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
#skip-grant-tables
 

ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO)

输入mysql出现该报错,只需加上用户名如(mysql -u root)即可。

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

看是不是设了密码,假如密码是123的话就输入 mysql -u root -p 123

如果忘了密码,可以重置密码。

先打开cmd,输入

net stop mysql

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

不要关闭当前cmd。然后再打开一个cmd,输入mysql -u root,此时应该不需要密码就能登录。再输入

flush privileges

ALTER USER 'root'@'localhost' IDENTIFIED BY '123';

这样你的密码就会被改为123。关掉所有cmd再打开,输入net start mysql,再重新登录应该就行了。

附:如果出现以下错误,检查你输入的alter语句是否与上文提到的相同。 

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 '' at line 1

其他常见问题

需要改mysql的服务类型?win+r然后输入

services.msc

需要改注册表路径?win+r然后输入

 regedit

net等指令提示不是内部或外部命令,也不是可运行的程序或批处理文件?去高级系统设置里的环境变量,系统变量中的Path中添加下面这条路径。

%SystemRoot%\system32 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值