CentOS下mysql的安装

前端之家收集整理的这篇文章主要介绍了CentOS下mysql的安装前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1、先查看本机上已经安装的MysqL

rpm –qa | grep -i MysqL

如果存在信息说明已经安装MysqL

需要完全卸载以前的MysqL

yum remove MysqL MysqL-server MysqL-libs compat-MysqL51

rm -rf /var/lib/MysqL

rm /etc/my.cnf

查看是否还有MysqL软件:
rpm -qa|grep MysqL

如果存在的话,继续删除即可

2、rpm方式安装的MysqL

查看系统中是否以rpm包安装的MysqL

[root@develop ~]# rpm -qa | grep -i MysqL
MysqL-server-5.6.24-1.rhel5.x86_64
[root@develop ~]#

b)卸载MysqL

[root@localhost local]#rpm -e MysqL-server-5.6.24-1.rhel5.x86_64

c)删除MysqL服务

[root@localhost local]# chkconfig --list | grep -i MysqL

[root@develop ~]# chkconfig --list | grep -i MysqL
MysqL 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭

[root@localhost local]# chkconfig --del MysqL

d)删除分散MysqL文件

[root@localhost local]# whereis MysqL 或者find / -name MysqL

MysqL: /usr/lib/MysqL /usr/share/MysqL

清空相关MysqL的所有目录以及文件
rm -rf /usr/lib/MysqL
rm -rf /usr/share/MysqL

rm -rf /usr/my.cnf

通过以上几步,MysqL应该已经完全卸载干净了

使用wget 直接在CentOS上下载MysqL(server、client)

提示wget:command not found,则需先安装wget。

yum install wget –y

下载

wget http://mysql.mirror.kangaroot.net/Downloads/MySQL-5.6/MySQL-server-5.6.24-1.rhel5.x86_64.rpm

wget http://mysql.mirror.kangaroot.net/Downloads/MySQL-5.6/MySQL-client-5.6.24-1.rhel5.x86_64.rpm

安装时若提Failed depaendencies:/usr/bin/perl is needed by MysqL-.......,则需安装perl

yum install perl -y

安装:

安装服务

rpm -ivh MysqL-server-5.6.24-1.rhel5.x86_64.rpm

安装客户端

rpm -ivh MysqL-client-5.6.24-1.rhel5.x86_64.rpm

conflicts with file from package MysqL-libs-5.1.....
包冲突,需将老版本的包卸载(删除)。

rpm -e MysqL-libs --nodeps

继续安装。。。

安装完毕,启动数据库

service MysqL start

输入:MysqLd

提示

这个是MysqL的权限问题。

永远不要使用root帐号启动MysqL Server。这样做很微笑,因为拥有FILE'权限的用户会使得MysqL Server使用root帐户创建文件(比如,~root/.bashrc),

为了防止类似的事情发生,MysqLd默认拒绝用户使用root帐户启动,但root用户可以通过在命令后面加上"--user=root"选项来强行启动MysqLd。

查看初始密码
cat /root/.MysqL_secret

设置密码

MysqL -uroot -p

粘贴查看到的初始密码
set password for 'root'@'localhost'=password('newpass');

设置MysqL为开机自动启动

首先查看MysqL是否是开机自动启动

-------------------------------------------------------

[root@localhost test]# chkconfig --list | grep MysqL
MysqLd 0:off 1:off 2:off 3:off 4:off 5:off 6:off

---------------------------------------------------------
我们发现MysqLd服务并没有开机自动启动,我们当然可以通过 chkconfig MysqLd on 命令来将其设置成开机启动,这样就不用每次都去手动启动了

设置初始化密码

MysqLadmin -u root password '123456'

test->show databases;

关闭MysqL数据库

service MysqL stop

3、卸载MysqL数据库

rpm -e MysqL-server

rpm -e MysqL-client

原文链接:https://www.f2er.com/centos/375903.html

猜你在找的CentOS相关文章