rhel yum安装mysql_RHEL5.6环境下yum安装MySQL

RHEL5.6环境下yum安装MySQL记录,2017年2月20日

1、卸载原有的MySQL

rpm -qa命令查询是否安装了MySQL

[root@localhost mysql]# rpm -qa|grepmysql

mysql-server-5.0.77-4.el5_5.4mysql-5.0.77-4.el5_5.4

使用rpm -e命令卸载安装包,如果卸载时提示依赖可以增加“--nodeps”参数;

如果想删除依赖项则直接卸载依赖项后再删除相应的包。

[root@localhost mysql]# rpm -e mysql-server-5.0.77-4.el5_5.4[root@localhost mysql]# rpm-e mysql-5.0.77-4.el5_5.4error: Failed dependencies:

libmysqlclient.so.15()(64bit) is needed by (installed) perl-DBD-MySQL-3.0007-2.el5.x86_64

libmysqlclient.so.15(libmysqlclient_15)(64bit) is needed by (installed) perl-DBD-MySQL-3.0007-2.el5.x86_64

[root@localhost mysql]# rpm-qa|grepMySQLperl-DBD-MySQL-3.0007-2.el5

[root@localhost mysql]# rpm-e perl-DBD-MySQL-3.0007-2.el5

[root@localhost mysql]# rpm-e mysql-5.0.77-4.el5_5.4

2、yum安装MySQL

查询yum源中是否具有MySQL服务。

[root@localhost yum.repos.d]# yum list | grepmysql

This system is not registered with RHN.

RHN support will be disabled.

apr-util-mysql.x86_64 1.2.7-11.el5_5.2base

bytefx-data-mysql.x86_64 1.2.4-2.el5.centos extras

freeradius-mysql.x86_64 1.1.3-1.6.el5 base

freeradius2-mysql.x86_64 2.1.12-5.el5 base

libdbi-dbd-mysql.x86_64 0.8.1a-1.2.2base

mod_auth_mysql.x86_641:3.0.0-3.2.el5_3 base

mysql.i3865.0.95-5.el5_9 base

mysql.x86_645.0.95-5.el5_9 base

mysql-bench.x86_64 5.0.95-5.el5_9 base

mysql-connector-odbc.x86_64 3.51.26r1127-2.el5 base

mysql-connector-odbc64.x86_64 5.1.8-1.el5 base

mysql-devel.i386 5.0.95-5.el5_9 base

mysql-devel.x86_64 5.0.95-5.el5_9 base

mysql-server.x86_64 5.0.95-5.el5_9 base

mysql-test.x86_64 5.0.95-5.el5_9 base

mysql51.x86_641-9.el5 base

mysql51-build.x86_64 1-9.el5 base

mysql51-mysql.x86_64 5.1.70-1.el5 base

mysql51-mysql-bench.x86_64 5.1.70-1.el5 base

mysql51-mysql-libs.x86_64 5.1.70-1.el5 base

mysql51-mysql-server.x86_64 5.1.70-1.el5 base

mysql51-mysql-test.x86_64 5.1.70-1.el5 base

mysql51-runtime.x86_64 1-9.el5 base

mysql55.x86_641-12.el5 base

mysql55-build.x86_64 1-12.el5 base

mysql55-mysql.x86_64 5.5.45-1.el5 update

mysql55-mysql-bench.x86_64 5.5.45-1.el5 update

mysql55-mysql-devel.i386 5.5.45-1.el5 update

mysql55-mysql-devel.x86_64 5.5.45-1.el5 update

mysql55-mysql-libs.x86_64 5.5.45-1.el5 update

mysql55-mysql-server.x86_64 5.5.45-1.el5 update

mysql55-mysql-test.x86_64 5.5.45-1.el5 update

mysql55-runtime.x86_64 1-12.el5 base

pdns-backend-mysql.x86_64 2.9.21-4.el5.centos extras

php-mysql.x86_64 5.1.6-45.el5_11 update

php-pear-MDB2-Driver-mysql.noarch 1.4.1-3.el5.centos extras

php53-mysql.x86_64 5.3.3-26.el5_11 update

qt4-mysql.x86_64 4.2.1-1.el5_7.1base

rsyslog-mysql.x86_64 3.22.1-7.el5 base

rsyslog5-mysql.x86_64 5.8.12-7.el5_11 update

[root@localhostyum.repos.d]#

安装MySQL及其相关服务

yum install -y mysql-server mysql mysql-devel

[root@localhost yum.repos.d]# rpm -qa|grepmysql

mysql-5.0.95-5.el5_9

mysql-devel-5.0.95-5.el5_9

mysql-devel-5.0.95-5.el5_9

mysql-5.0.95-5.el5_9

mysql-server-5.0.95-5.el5_9

可以看到mysql安装的包。

3、配置MySQL

3.1、查看MySQL服务状态

[root@localhost yum.repos.d]# service mysqld status

mysqld is stopped

3.2、启动MySQL服务

[root@localhost yum.repos.d]# service mysqld start

Initializing MySQL database: Installing MySQL system tables...

OK

Filling help tables...

OK

To start mysqld at boottimeyou have to copy

support-files/mysql.server to the right place foryour system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER!Todo so, start the server, thenissue the following commands:/usr/bin/mysqladmin -u root password 'new-password'

/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'Alternatively you can run:/usr/bin/mysql_secure_installationwhichwill also give you the option of removing the test

databases and anonymous user created by default. This is

strongly recommendedforproduction servers.

See the manualfor moreinstructions.

You can start the MySQL daemon with:

cd/usr ; /usr/bin/mysqld_safe &You can test the MySQL daemon with mysql-test-run.pl

cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the/usr/bin/mysqlbug script!The latest information about MySQL is available on the web at

http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

[ OK ]

Starting mysqld: [ OK ]

[root@localhostyum.repos.d]#

查看MySQL服务状态:

[root@localhost yum.repos.d]# service mysqld status

mysqld (pid5806) is running...

在终端中敲入mysql命令可以直接进入mysql命令行,此时MySQL没有设置登录密码。

[root@localhost yum.repos.d]# mysql

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

Your MySQL connectionid is 2Server version:5.0.95Source distribution

Copyright (c)2000, 2011, 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 clearthe current input statement.

mysql>

3.3、启用MySQL登录密码:

[root@localhost yum.repos.d]# mysqladmin -u root password "passw0rd"

再次敲入mysql提示登录信息:

[root@localhost yum.repos.d]# mysql

ERROR1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

使用密码登录MySQL:

[root@localhost yum.repos.d]# mysql mysql -u root -p

Enter password:

Reading table informationforcompletion of table and column names

You can turn off this feature to get a quicker startup with-A

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

Your MySQL connectionid is 5Server version:5.0.95Source distribution

Copyright (c)2000, 2011, 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 clearthe current input statement.

mysql>

3.4、允许root账号远程登录:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'passw0rd'WITH GRANT OPTION;

Query OK,0 rows affected (0.00 sec)

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值