MySQL非root用户执行增加用户及用户权限的操作
2015-11-05 23:25
671 查看
第一步:
$ sudo /etc/init.d/mysql stop
[ ok ] Stopping MySQL database server: mysqld.
$ sudo /usr/bin/mysqld_safe --skip-grant-tables&
[2] 19668
151105 21:12:43 mysqld_safe Logging to syslog.
151105 21:12:43 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
第二步:(进入MySQL)
~$ mysql
mysql> use 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> insert into user(Host,User,Password) values("localhost","test",password("1234"));
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
mysql> GRANT ALL PRIVILEGES ON *.* TO 'test'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
执行这句时候有可能出错:
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> GRANT ALL PRIVILEGES ON *.* TO IDENTIFIED BY '123' WITH GRANT OPTION;
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
这个时候我们只需要
mysql> flush privileges; 就好了!!
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
第三步:
~$ sudo /etc/init.d/mysql start
$ sudo /etc/init.d/mysql stop
[ ok ] Stopping MySQL database server: mysqld.
$ sudo /usr/bin/mysqld_safe --skip-grant-tables&
[2] 19668
151105 21:12:43 mysqld_safe Logging to syslog.
151105 21:12:43 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
第二步:(进入MySQL)
~$ mysql
mysql> use 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> insert into user(Host,User,Password) values("localhost","test",password("1234"));
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
mysql> GRANT ALL PRIVILEGES ON *.* TO 'test'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
执行这句时候有可能出错:
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> GRANT ALL PRIVILEGES ON *.* TO IDENTIFIED BY '123' WITH GRANT OPTION;
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
这个时候我们只需要
mysql> flush privileges; 就好了!!
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
第三步:
~$ sudo /etc/init.d/mysql start
相关文章推荐
- mysql 学习记录(二十三)--mysql安装时相关优化
- Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
- MySQL数据库性能优化之缓存参数优化
- ubuntu上使用mysql数据库连接rails项目
- MySQL数据库中缓存管理的思路解析
- Mysql压缩包版的安装方法
- mysqldump参数大全
- [实战]MVC5+EF6+MySql企业网盘实战(14)——思考
- JBoss7部署EJB连接MySQL
- paip.解决 数据库mysql增加列 字段很慢添加字段很慢
- Mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost'问题的解决
- mysql select中子查询中使用强制索引的优化案例
- Error 2002 (HY000): Can't connect to local MySOL server through socket '/var/lib/mysql.sock' (2 "No
- mysql版本 5.6.10,UNIX_TIMESTAMP和FROM_UNIXTIME支持最大时间戳转换
- mysql order by注入技巧
- MySQL安全配置详解
- mysql热备份
- mysql修改配置文件进行优化
- MySQL意外断电,InnoDB数据库恢复
- MySQL数据库的分区表、存储过程、event定时任务的创建