1. shell>MySQL -u root -p
2. MySQL> update user set passwordpassword=password(”xueok654123″) where user=’root’;
MySQL> flush privileges //刷新数据库
MySQL>use dbname; 打开数据库:
MySQL>show databases; 显示所有数据库
MySQL>show tables; 显示数据库MySQL中所有的表:先use MySQL;然后
MySQL>describe user; 显示表MySQL数据库中user表的列信息);
3、grant
创建一个可以从任何地方连接服务器的一个完全的超级用户,但是必须使用一个口令something做这个
MySQL> grant all privileges on *.* to user@localhost identified by ’something’ with
增加新用户
格式:grant select on 数据库.* to 用户名@登录主机 identified by “密码”
1. GRANT ALL PRIVILEGES ON *.* TO monty@localhost IDENTIFIED BY ’something’ WITH GRANT OPTION;
2. GRANT ALL PRIVILEGES ON *.* TO monty@”%” IDENTIFIED BY ’something’ WITH GRANT OPTION;
删除授权:
1. MySQL> revoke all privileges on *.* from root@”%”;
2. MySQL> delete from user where user=”root” and host=”%”;
3. MySQL> flush privileges;
创建一个用户custom在特定客户端it363.com登录,可访问特定数据库fangchandb
1. MySQL >grant select, insert, update, delete, create,drop on fangchandb.* to custom@ it363.com identified by ‘ passwd’