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

 2023-09-05 阅读 152 评论 0

摘要:查看操作系统版本 cat /etc/redhat-release 这个命令就会查看该操作系统上是否已经安装了mysql数据 rpm -qa | grep mysql [root@larry ~]# rpm -e mysql  // 普通删除模式 [root@larry ~]# rpm -e --nodeps mysql  // 强力删除模式,如果使用上面命令删除

查看操作系统版本

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.centossysstat.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_installationwhich 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
centos7

下载

wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
安装
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-server
重启
service mysqld restart

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/1/932.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息