centos 查看mysql 服务器配置_在CentOS上MySQL数据库服务器配置方法

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;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值