mysql (mariadb) 数据库权限

MySQL只有information_schema数据库

1.记得要root权限,用 mysql -uroot -p root登录,出现:

如果没有权限进入mysql,可以使用非权限进入方式:

  mysqld_safe --skip-grant-tables

  mysql> use mysql;

  mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root';

  mysql> FLUSH PRIVILEGES;

MySQL报错:The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

解决办法:

mysql> set global read_only=0;  
Query OK, 0 rows affected (0.00 sec)  
  
mysql> show variables like '%read_only%';  
+------------------+-------+  
| Variable_name    | Value |  
+------------------+-------+  
| innodb_read_only | OFF   |  
| read_only        | OFF   |  
| tx_read_only     | OFF   |  
+------------------+-------+  
3 rows in set (0.00 sec)  
  
mysql> set global read_only=1;  
Query OK, 0 rows affected (0.00 sec)  
  
mysql> show variables like '%read_only%';  
+------------------+-------+  
| Variable_name    | Value |  
+------------------+-------+  
| innodb_read_only | OFF   |  
| read_only        | ON    |  
| tx_read_only     | OFF   |  
+------------------+-------+  
3 rows in set (0.00 sec)  
  
set global read_only=0;  关闭只读,可以读写  
  
set global read_only=1; 开始只读模式  

mysql设置用户权限以及远程登陆权限(修改数据库)

首先配置允许访问的用户,采用授权的方式给用户权限

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '123456' WITH GRANT OPTION;

 

 说明:root是登陆数据库的用户,123456是登陆数据库的密码,*就是意味着任何来源任何主机反正就是权限很大的样子。

最后配置好权限之后不应该忘记刷新使之生效

flush privileges;

 再次访问就可以了吧。

补充:mysql没有密码是不能写入数据(只能使用select查看)

 

posted @ 2017-05-25 13:53  Auler  阅读(448)  评论(0编辑  收藏  举报