💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
[TOC] ## 1. 修改root密码(关闭安全模式) 1. 停止正在运行的MySQL进程 【Linux】运行 killall -TERM mysqld 2. 以安全模式启动MySQL ~~~ 【Linux】运行 /usr/local/mysql/bin/mysqld_safe --skip-grant-tables & 【Windows】在命令行下运行 X:/MySQL/bin/mysqld-nt.exe --skip-grant-tables ~~~ 3. 完成以后就可以不用密码进入MySQL了 ~~~ 【Linux】运行 /usr/local/mysql/bin/mysql -u root -p 进入 【Windows】运行 X:/MySQL/bin/mysql -u root -p 进入 ~~~ 4. 更改密码 ~~~ >use mysql >update user set password=password("新密码") where user="root"; >flush privileges; ~~~ ## 2. 允许用户远程访问 ~~~ mysql>grant all privileges on *.* to root@'%' identified by 'tuna'; mysql>flush privileges; ~~~ ## 3. 查看当前使用的配置文件 ~~~ /usr/bin/mysql --verbose --help | grep -A 1 'Default options' ~~~ ## 4. 查看用户权限 ~~~ mysql> show grants for 'systop'@'%'; ERROR 1141 (42000): There is no such grant defined for user 'systop' on host '%' mysql> show grants for 'systop'@'192.168.56.%'; +-----------------------------------------------------------+ | Grants for systop@192.168.56.% | +-----------------------------------------------------------+ | GRANT REPLICATION SLAVE ON *.* TO 'systop'@'192.168.56.%' | +-----------------------------------------------------------+ 1 row in set (0.00 sec) ~~~