首页 > 数据库 >Centos 7安装MySQL5.6

Centos 7安装MySQL5.6

时间:2023-04-27 09:33:05浏览次数:53  
标签:log Centos mysql rpm MySQL5.6 mysqld MySQL yum 安装

安装步骤

  确保之前未安装;若存在则要卸载

// 查看主机是否已经安装了mysql(如果存在则要卸载)
rpm -qa|grep mysql
// 卸载命令
rpm -e --nodeps "上面检索出的mysql安装包"

  下载mysql的yum源

wget -P /usr/software http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
// 验证是否下载成功
ll /usr/software/

  安装下载好的yum源

cd /usr/software/
rpm -ivh mysql-community-release-el6-5.noarch.rpm
ll /etc/yum.repos.d

  使用yum安装MySQL服务器

yum search mysql
yum install -y mysql-community-server

  启动MySQL服务并查看状态

service mysqld start
service mysqld status

  修改MySQL密码

// mysql5.6 安装完成后,它的 root 用户的密码默认是空的,我们需要及时用 mysql 的 root 用户登录(第一次直接回车,不用输入密码),并修改密码。
mysql -u root

mysql> use mysql;
mysql> update user set password=PASSWORD("这里输入root用户密码") where User='root';
mysql> flush privileges;

 

遇到的问题

  查看mysql服务器状态,发现是正常启动的,但就是无法连接MySQL,报如下错误

Can't connect to local MySQL server through socket '/tmp/mysql.sock'

  解决方法就是在/etc/my.cnf里面添加一个[client]

// 要保证[mysqld]和[client]终端socket路径一样
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid


[client]
socket = /var/lib/mysql/mysql.sock

参考链接

[1]https://www.cnblogs.com/gscq073240/articles/16730724.html

[2]https://blog.csdn.net/pengjunlee/article/details/81212250

[3]https://blog.csdn.net/qq_42347255/article/details/113700167

[4]https://www.jb51.net/article/174244.htm

标签:log,Centos,mysql,rpm,MySQL5.6,mysqld,MySQL,yum,安装
From: https://www.cnblogs.com/ReturnOfTheKing/p/17357977.html

相关文章

  • Kubernetes(K8S) kubesphere 安装
    安装KubeSphere最好的方法就是参考官方文档,而且官方文档是中文的。官网地址:https://kubesphere.com.cn/https://github.com/kubesphere/kubesphere/blob/master/README_zh.mdKubernetes(K8S)kubesphere介绍安装提前条件:使用Kubeadm部署Kubernetes(K8S)安装--附K8S架构......
  • pip安装cuda版torch
    一开始安装torch的时候没有指定cuda版本,所以安装的是cpu版本,无法调用gpu可以使用如下安装方法:pipinstalltorch-fhttps://download.pytorch.org/whl/cu118/torch_stable.html(应该可以用)pipinstall torch --index-urlhttps://download.pytorch.org/whl/nightly/cu......
  • openldap安装指南
    #ldapserver#安装openldapsetenforce0&&systemctlstopfirewalld&&iptables-Fyuminstall-yepel-releaseyuminstall-yopenldapopenldap-clientsopenldap-serverssystemctlstartslapdsystemctlenableslapdsystemctlstatusslapd......
  • Linux安装
    1Linux系统安装1.1Unix哲学思想一切都是一个文件(包括硬件)小型,单一用途的程序链接程序,共同完成复杂的任务(shell脚本)避免令人困惑的用户界面配置数据存储在文本中1.2Linux各种版本CentOS各版本介绍https://zh.wikipedia.org/wiki/CentOSRHEL各版本介绍https://zh.wikipe......
  • windows安装mariaDB失败,服务不能启动
    (lay旧文章整理)于2019-02-0620:17:59发布过年了,在老家闲余时间想敲敲代码,发现在安装mariaDb的时候一直报错错误信息:Service‘MySQL’(MySQL)Faildtostart,Verifythatyouhavesuffcientprivilegestostartsystemservices.服务的MySQL(MySQL)启动错误,确认你有权限启......
  • 解决VMware Workstation安装VMware Tools显示灰色的办法
    想在VMwareWorkstation中安装VMwareTools,方便文件的复制粘贴。但是如下图,总是灰色按照网上教程设置方法一:1.关闭虚拟机;2.在虚拟机设置分别设置CD/DVD、CD/DVD2和软盘为自动检测三个步骤;3.再重启虚拟机,灰色字即点亮。灰色没有点亮。 接着尝试了方法二:1.关闭虚......
  • mac 上安装redis
    苹果电脑可以通过Homebrew来安装Redis。请按照以下步骤进行操作:1.打开Terminal(终端)应用程序2.输入以下命令以安装Homebrew:```/bin/bash-c"$(curl-fsSLhttps://raw.githubusercontent.com/Homebrew/install/master/install.sh)"```3.输入以下命令以更新Homebrew,并检查是......
  • centos7更换yum源 一条命令搞定
    yuminstall-ywget&&mv/etc/yum.repos.d/CentOS-Base.repo/etc/yum.repos.d/CentOS-Base.repo.backup&&wget-O/etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-7.repo&&yumcleanall&&yummakecach......
  • Jmeter插件管理器安装
    打开Jmeter官网:https://jmeter-plugins.org/install/Install/点击下载插件: jmeter-plugins-manager-1.8.jar,如下图: 将下载的插件放到Jmeter安装包的lib/ext目录下,然后重启Jmeter ......
  • eclipse maven 安装、配置
    在http://maven.apache.org/download.cgi下载maven包,解压后,设置一下环境变量Path,把maven的路径加进去,像设置java环境变量一样。打开eclipse,菜单Help->InstallNewSoftware,如图:输入的URL为http://download.eclipse.org/technology/m2e/releases名称随便取,我取的是m2e。然后安装。......