赞
踩
http://www.jb51.net/article/23255.htm
========================
1 . 无密码登录:
mysql -u root
在已经有密码的情况下报错:
[root@zcping-host ~]# mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
2. 通过密码用root登录
mysql -u root -p
[root@zcping-host ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 44
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, 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>
3. 查看用户信息
select user,host,password from mysql.user;
mysql> select user,host,password from mysql.user;
+------+-----------------------+-------------------------------------------+
| user | host | password |
+------+-----------------------+-------------------------------------------+
| root | localhost | *9E39CD1D3CDD47DEE6AFE57A28141C1C1284C65D |
| root | ay140715181719715ea5z | *9E39CD1D3CDD47DEE6AFE57A28141C1C1284C65D |
| root | 127.0.0.1 | *9E39CD1D3CDD47DEE6AFE57A28141C1C1284C65D |
+------+-----------------------+-------------------------------------------+
3 rows in set (0.00 sec)
mysql>
4. 设置root密码
set password for root@localhost=password('密码');
set password for root@'www.xxx.com'=password('密码');
5. 退出服务器
exit
6. 删除匿名用户
mysql -u root -p
select user,host from mysql.user;
delete from mysql.user where user='';
删除测试用数据库
mysql -u root -p
show databases;
drop database test;
show databases;
exit;
创建用户:create user 'xxxxx'@'localhost' identified by 'xxxxxxxxx'
创建对test数据库有完全操作权限的名为centospub的用户
grant all privileges on test.* to centospub@localhost identified by '密码’; select user from mysql.user where user='centospub'; 用新建立的centospub用户登录mysql服务器 mysql -u centospub -p 创建数据库 create database test; show databases; 连接到数据库 use test create table test(num int,name varchar(50)); show tables; insert into test values(1,'hello world!'); select * from test; 删除测试过的遗留用户 revoke all privileges on *.* from centospub@localhost; delete from mysql.user where user='centospub' and host='localhost'; 刷新,使以上操作生效 flush privileges;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。