mysql 分配权限

有时候你没有其他账号,或者你把账号很邪恶的设置成用户名密码都是 ‘’的时候,

你输入mySql是采用默认用户登录的 即使-u也没用

那么如何赋予 ‘’其他权限呢。

在linux 终端执行:

1.killall -TERM mysqld  

2. 

[root@TSMIS bin]# /etc/init.d/mysqld start  --skip-grant-tables   

  3.

3.1 用登录mysql 

然后就可以grant all on *.* to ''@'localhost' identified by '';

搞定 

Insert mode
[root@localhost mysql]# killall -TERM mysqld
[root@localhost mysql]# /etc/init.d/mysql start --skip-grant-tables;
Starting MySQL.                                            [  OK  ]
[root@localhost mysql]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.28-rc-community MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> srae mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> truncate user;
Query OK, 0 rows affected (0.00 sec)
mysql>  insert into user( Host, User , Password , Select_priv , Insert_priv , Update_priv , Delete_priv , Create_priv , Drop_priv , Reload_priv , Hutdown_priv , Process_priv , File_priv , Grant_priv , References_priv , Index_priv , Alter_priv , Show_db_priv , Super_priv , Create_tmp_table_priv , Lock_tables_priv , Execute_priv , Repl_slave_priv , Repl_client_priv , Create_view_priv , Show_view_priv , Create_routine_priv , Alter_routine_priv , Create_user_priv) valuse('%','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
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 'valuse('%','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'' at line 1
mysql>  insert into user( Host, User , Password , Select_priv , Insert_priv , Update_priv , Delete_priv , Create_priv , Drop_priv , Reload_priv , Shutdown_priv , Process_priv , File_priv , Grant_priv , References_priv , Index_priv , Alter_priv , Show_db_priv , Super_priv , Create_tmp_table_priv , Lock_tables_priv , Execute_priv , Repl_slave_priv , Repl_client_priv , Create_view_priv , Show_view_priv , Create_routine_priv , Alter_routine_priv , Create_user_priv) values('%','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
Query OK, 1 row affected, 3 warnings (0.00 sec)
mysql> exit;
Bye
[root@localhost mysql]# /etc/init.d/mysql restart
Shutting down MySQL.                                       [  OK  ]
Starting MySQL.                                            [  OK  ]
[root@localhost mysql]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.28-rc-community MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use test;
Database changed
mysql> create table hello(name char(29));
Query OK, 0 rows affected (0.00 sec)
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| hello          | 
+----------------+

1 row in set (0.00 sec)

TSMIS软件会把mysql的数据迁移到  $TSMISi目录下,所以我们要修改etc init.d mysql 下的datafile的路径,然后重启就可以了

Insert mode
原文地址:https://www.cnblogs.com/xianqingzh/p/2024727.html