centos6.5 使用 rpm 安装 mysql

Posted 赖荣生

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos6.5 使用 rpm 安装 mysql相关的知识,希望对你有一定的参考价值。

mysql网站下载mysql rpm安装包(包括server、client)

1、安装server

rpm -ivh MySQL-server-5.6.19-1.el6.x86_64.rpm

强制安装

rpm -ivh --force MySQL-server-5.5.17-1.linux2.6.x86_64.rpm

报如下错误

[[email protected] ~]# rpm -ivh MySQL-server-5.6.19-1.el6.x86_64.rpm --nodepsPreparing...                          ################################# [100%]     
file /usr/share/mysql/charsets/README from install of MySQL-server-5.6.19-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.40-1.el7_0.x86_64

原因是与之前lib库冲突,解决方式删除老版本lib库(注意根据你的提示更改相应版本)

yum -y remove mariadb-libs-1:5.5.40-1.el7_0.x86_64* 
yum -y remove mysql-libs-*

再次执行 rpm -ivh MySQL-server-5.6.19-1.el6.x86_64.rpm 即可安装成功

报如下错误

[[email protected] tools]# rpm -ivh MySQL-server-5.6.19-1.el6.x86_64.rpm 
error: Failed dependencies:
/usr/bin/perl is needed by MySQL-server-5.6.19-1.el6.x86_64
libaio.so.1()(64bit) is needed by MySQL-server-5.6.19-1.el6.x86_64
libaio.so.1(LIBAIO_0.1)(64bit) is needed by MySQL-server-5.6.19-1.el6.x86_64
libaio.so.1(LIBAIO_0.4)(64bit) is needed by MySQL-server-5.6.19-1.el6.x86_64

需要安装 libaio

报如下错误,错少perl安装perl

error: Failed dependencies: 
 /usr/bin/perl is needed by MySQL-server-5.6.19-1.el6.x86_64

安装perl

yum install perl

2、启动mysql
启动

service mysql start 

停止

service mysql stop 

重启

service mysql restart 

查看当前mysql状态

service mysql status

3、安装client

rpm -ivh MySQL-client-5.6.19-1.el6.x86_64.rpm

4、客户端登陆 

mysql -uroot -p

5、mysql初始化

[[email protected] mysql]# /usr/bin/mysql_install_db
[[email protected] mysql]# service mysql start
[[email protected] mysql]# cat /root/.mysql_secret
# The random password set for the root user at Sat Feb 7 10:54:24 2015 (local time): VoKvw3vpo_3LiA3c
[[email protected] mysql]# mysql -uroot -pVoKvw3vpo_3LiA3c
mysql> SET PASSWORD = PASSWORD(‘2345678‘);
mysql> exit
[[email protected] mysql]# mysql -uroot -p2345678

6、远程登录配置

mysql> use mysql
mysql> select host ,user ,password from user;
+-----------+------+-------------------------------------------+
| host | user | password |
+-----------+------+-------------------------------------------+
| localhost | root | *BC1C4715C23459AB982AD2D6617B4F8790161763 |
| xcldtc5m | root | *44CF61DA6CDeeee2085F4598F728CF221DA8F167 |
| 127.0.0.1 | root | *44CF61DA6CD83e32085F4598F728CF221DA8F167 |
| ::1 | root | *44CF61DA6CD86832345F4598F728CF221DA8F167 |
+-----------+------+-------------------------------------------+
mysql> update user set password=password(‘234567‘) where user=‘root‘;
mysql> update user set host=‘%‘ where host=‘localhost‘;

重新启动mysql或是刷新

7、设置开机自启动

[[email protected] mysql]# chkconfig mysql on
[[email protected] mysql]# chkconfig --list | grep mysql
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off

8、查看mysql配置文件位

[[email protected] mysql]# mysqld --verbose --help | grep -A 1 ‘Default options‘

9、MYSQL默认安装位置

/var/lib/mysql/ #数据库目录 /usr/share/mysql #配置文件目录
/usr/bin #相关命令目录 /etc/init.d/mysql #启动脚本

10、更改mysql默认引擎为Innodb

在配置文件my.ini中的 [mysqld] 下面加入default-storage-engine=INNODB
之后重启即可

  

  

  

  




以上是关于centos6.5 使用 rpm 安装 mysql的主要内容,如果未能解决你的问题,请参考以下文章

CentOS6.5 安装配置mysql(转)

centos7和centos6.5环境rpm方式安装mysql5.7和mysql5.6详解

Centos6.5下编译安装mysql 5.6

CentOS6.5系统下RPM包安装MySQL5.6

CentOS6.5源码安装MySQL5.6.35

CentOS6.5系统下RPM包安装MySQL5.6(转)