centos怎么查看mysql版本_centos上安装Mysql 和查看mysql库版本

1 安装环境:

a) CentOS release 5.8

b) 查看当前linux系统版本:

root@master conf]# lsb_release -a

LSB Version: :core-4.0-ia32:core-4.0-noarch:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-ia32:printing-4.0-noarch

Distributor ID: CentOS

Description: CentOS release 5.8 (Final)

Release: 5.8

Codename: Final

2 安装方式:  yum在线安装

3 安装流程:

如下MySQL安装是在master机器上安装的:

[root@master local]# yum install mysql-server 安装

...

Dependency Installed:

mysql.i386 0:5.0.95-5.el5_9 perl-DBD-MySQL.i386 0:3.0007-2.el5

perl-DBI.i386 0:1.52-2.el5

Complete!

[root@master local]# service mysqld start 启动mysql

...

[ OK ]

Starting mysqld: [ OK

[root@master local]# service mysqld status

mysqld (pid 27645) is running...

[root@master local]# mysql -uroot

mysql> use mysql;

mysql> show tables;

mysql> select password,user from user;

+----------+------+

| password | user |

+----------+------+

| | root |

| | root |

| | root |

| | |

| | |

+----------+------+

mysql> update user set password=password('admin') ----> 给usr表设置加密密码

-> ;

mysql> select password,user from user;

+------------------+------+

| password | user |

+------------------+------+

| 43e9a4ab75570f5b | root |

| 43e9a4ab75570f5b | root |

| 43e9a4ab75570f5b | root |

| 43e9a4ab75570f5b | |

| 43e9a4ab75570f5b | |

+------------------+------+

mysql> flush privileges; ----> 设置生效 并退出MySQL

Query OK, 0 rows affected (0.00 sec)

mysql> exit;

Bye

[root@master local]# mysql -uroot -padmin ----> 重新以有密码方式登录MySQL

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 4

给集群别的机器设置当前安装的MySQL访问授权:

解释如下:

mysql> grant all on *.* to 'root'@'%' identified by 'admin';

授予所有权限(all 比如增删改查) 在(on) 所有的表.所有的数据库

给(to) root用户@所有机器上的(%表示) 对应的密码是 admin

这样对集群中所有用户为root 密码为admin的用户都能对当前安装的MySQL

内所有数据库和表都授予所有操作权限了。

命令如下:

mysql> grant all on *.* to 'root'@'%' identified by 'admin';

Query OK, 0 rows affected (0.10 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

这样,假如我在103机器上也安装了MySQL服务(此时103机器的MySQL服务可以不启动),

[root@sliver103 network-scripts]# mysql -hmaster -uroot -padmin

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 6

Server version: 5.0.95 Source distribution

也可以进入到master的MySQL内执行命令。

4  常见报错:

a) Ignoring query to other XXX

[root@master local]# mysql -root

mysql> show databases;

Ignoring query to other database

mysql> show tables;

Ignoring query to other database

mysql> exit;

Bye

错误原因:

折腾了半天才发现原来是在连接mysql时没有"-u"参数导致的

D:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -uroot

重新连接mysql 加上-u参数 一切正常

[root@master local]# mysql -uroot

查看mysql库版本:

[root@master ~]# mysql -V

mysql  Ver 14.14 Distrib 5.6.24, for Linux (x86_64) using  EditLine wrapper

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值