mysql root 没有任何权限

摘要:
问题:mysqlroot没有任何权限解决方案1.addskip-grant-tablesin/etc/my。文件[root@mysql~]#猫/etc/my。cnf|grep-iskipskip-grant tables2.startmysqlsystemctlrestartmysqld3.添加权限mysql˃usemysqlDatabasechangedmysql˃updateuse

问题:

mysql root 没有任何权限

解决方案

1. add skip-grant-tables in /etc/my.conf

[root@mysql~]# cat /etc/my.cnf|grep -i skip
skip-grant-tables

2. restart mysql

systemctl restart mysqld

3.增加权限

mysql> use mysql
Database changed
mysql> update user set Host='%',select_priv='y' where user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0
mysql> update user set Host='%',insert_priv='y',update_priv='y',Alter_priv='y',delete_priv='y',create_priv='y',drop_priv='y',reload_priv='y',shutdown_priv='y',Process_priv='y',file_priv='y',grant_priv='y',References_priv='y',index_priv='y',create_user_priv='y',show_db_priv='y',super_priv='y',create_tmp_table_priv='y',Lock_tables_priv='y',execute_priv='y',repl_slave_priv='y',repl_client_priv='y',create_view_priv='y',show_view_priv='y',create_routine_priv='y',alter_routine_priv='y',create_user_priv='y' where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> commit;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye

4.  remove skip-grant-tables in /etc/my.conf

5.restart mysql

[root@mysql~]# systemctl restart mysqld
[root@mysql~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 8
Server version: 8.0.20 MySQL Community Server - GPL

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mydb               |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)


免责声明:文章转载自《mysql root 没有任何权限》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇iOS绘制手势解锁密码U盘启动安装 window server 2003下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

存储过程中SELECT INTO的使用

在MySQL存储过程中使用SELECT …INTO语句为变量赋值:   用来将查询返回的一行的各个列值保存到局部变量中。 要求:   查询的结果集中只能有1行。 SELECT col_name[,...] INTO var_name[,...] table_expr 使用SELECT …INTO语句在数据库中进行查询,并将得到的结果赋值给变量。   ①co...

MySQL 5.7贴心参数之binlog_row_image

相信大家都了解mysql binlog的格式,那就是有三种,分别是STATEMENT,MiXED,ROW。各有优劣,具体的请大家自行查阅资料。在MySQL 5.7版本以前,虽然ROW格式有各种各样的好处。 1. 比如加快从库重放日志;ROW直接调用mysql的存储引擎接口(handler API) 来执行行的插入、删除和更新,完全跳过了mysql的优化器的...

批处理命令篇--配置免安装mysql

免安装版的mysql是进行软件绿色发布的绝佳助手,本文介绍一种使用批处理命令自动配置mysql的方法。 (1)建立三个文件,分别是:service install.bat,temp.txt,update.sql。 (2)在temp.txt文件中写入如下内容: set PathTemp= (3)在update.sql文件中写入如下内容: use mysql...

MySQL 行锁 表锁机制

MySQL 表锁和行锁机制 行锁变表锁,是福还是坑?如果你不清楚MySQL加锁的原理,你会被它整的很惨!不知坑在何方?没事,我来给你们标记几个坑。遇到了可别乱踩。通过本章内容,带你学习MySQL的行锁,表锁,两种锁的优缺点,行锁变表锁的原因,以及开发中需要注意的事项。还在等啥?经验等你来拿! MySQL的存储引擎是从MyISAM到InnoDB,锁从表锁到行...

mysql(4)—— 表连接查询与where后使用子查询的性能分析。

子查询就是在一条查询语句中还有其它的查询语句,主查询得到的结果依赖于子查询的结果。 子查询的子语句可以在一条sql语句的FROM,JOIN,和WHERE后面,本文主要针对在WHERE后面使用子查询与表连接查询的性能做出一点分析。 对于表连接查询和子查询性能的讨论众说纷纭,普遍认为的是表连接查询的性能要高于子查询。本文将从实验的角度,对这两种查询的性能做出验...

Nginx负载均衡会话共享

    在使用负载均衡的时候会遇到会话保持的问题,可通过如下方式进行解决 1.使用nginx的ip_hash,根据客户端的来源IP,将请求分配到相同服务器上 2.基于服务端的Session会话共享(mysql/memcache/redis/file)   在解决负载均衡会话问题我们需要了解session和cookie。 1.用户第一次请求服务端网站时,服务...