centos6 yum安装mysql客户端和rpm包方式安装方式

前端之家收集整理的这篇文章主要介绍了centos6 yum安装mysql客户端和rpm包方式安装方式前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

查看操作系统版本

cat /etc/redhat-release

这个命令就会查看该操作系统上是否已经安装了MysqL数据

rpm -qa | grep MysqL

[root@larry ~]# rpm -e MysqL  // 普通删除模式 
[root@larry ~]# rpm -e --nodeps MysqL  // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除

通过yum的方式来进行MysqL数据库安装,首先我们可以输入 yum list | grep MysqL 命令来查看yum上提供的MysqL数据库可下载的版本:

[root@ren ~]# yum list | grep MysqL

安装:

yum install -y MysqL-deve

连接:

MysqL -hRDSURL地址 -u账户 -p密码 -P3306

rpm安装

[root@AY14061209501523080aZ soft]# rpm -qa|grep MysqL
MysqL-libs-5.1.73-7.el6.x86_64
[root@AY14061209501523080aZ soft]# yum remove MysqL MysqL-server MysqL-libs compat-MysqL51
已加载插件:fastestmirror
设置移除进程
参数 MysqL 没有匹配
.....
删除:
  MysqL-libs.x86_64 0:5.1.73-7.el6

作为依赖被删除:
  cronie.x86_64 0:1.4.4-15.el6_7.1      cronie-anacron.x86_64 0:1.4.4-15.el6_7.1      crontabs.noarch 0:1.10-33.el6      postfix.x86_64 2:2.6.6-6.el6_7.1      redhat-lsb-core.x86_64 0:4.0-7.el6.centos
  sysstat.x86_64 0:9.0.4-31.el6

完毕!
[root@AY14061209501523080aZ soft]# rm -rf /var/lib/MysqL
[root@AY14061209501523080aZ soft]# rm /etc/my.cnf
rm: 无法删除"/etc/my.cnf": 没有那个文件或目录
[root@AY14061209501523080aZ soft]# rpm -qa|grep MysqL
apache-tomcat-8.5.11.tar.gz  jdk-7u51-linux-x64.rpm  MysqL-client-5.6.17-1.linux_glibc2.5.x86_64.rpm  MysqL-server-5.6.17-1.linux_glibc2.5.x86_64.rpm
[root@AY14061209501523080aZ soft]# rpm -ivh MysqL-client-5.6.17-1.linux_glibc2.5.x86_64.rpm MysqL-server-5.6.17-1.linux_glibc2.5.x86_64.rpm
Preparing...                ########################################### [100%]
   1:MysqL-server           ########################################### [ 50%]

MysqL安装成功!但不接受任何命令,除非先设置密码(SET PASSWORD),默认密码放到 '/root/.MysqL_secret'里了

A RANDOM PASSWORD HAS BEEN SET FOR THE MysqL root USER !
You will find that password in '/root/.MysqL_secret'.

You must change that password on your first connect,no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.

Also,the account for the anonymous user has been removed.

In addition,you can run:

  /usr/bin/MysqL_secure_installation

which will also give you the option of removing the test database.
This is strongly recommended for production servers.

See the manual for more instructions.

设置密码

查看密码

[root@AY14061209501523080aZ ~]# cat .MysqL_secret
# The random password set for the root user at Thu Apr  6 19:48:27 2017 (local time): kejppq4v1V

启动登录

[root@AY14061209501523080aZ ~]# service MysqL start
Starting MysqL. SUCCESS!
[root@AY14061209501523080aZ ~]# MysqL -u root -p
Enter password:kejppq4v1V
Welcome to the MysqL monitor.  Commands end with ; or \g.
Your MysqL connection id is 1
Server version: 5.6.17

设置新密码

MysqL> set password = password('slei159');
Query OK,0 rows affected (0.00 sec)

推出重新登录

MysqL> exit
Bye
[root@AY14061209501523080aZ ~]# MysqL -u root -p
Enter password:
Welcome to the MysqL monitor.  Commands end with ; or \g.
Your MysqL connection id is 2
Server version: 5.6.17 MysqL Community Server (GPL)

Copyright (c) 2000,2014,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>

初始化数据库

会问你要数据库密码,输入即可,不然不让你继续设置,然后又问你是否需要修改root的密码,我们刚才设置了,所以没有必要,输入n就可以,剩下的一路回车,要知道在这个设置里,回车=Y,但是到其他地方可不一定是这样。

/usr/bin/MysqL_secure_installation

设置编码

vim /usr/my.cnf

[client]
default-character-set=utf8

[MysqL]
default-character-set=utf8

[MysqLd]
default-storage-engine = MyISAM
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
原文链接:https://www.f2er.com/centos/379961.html

猜你在找的CentOS相关文章