1、下载安装包

首先查看Linux版本:

[root@localhost ~]# lsb_release -a
LSB Version: :core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 6.3 (Santiago)
Release: 6.3
Codename: Santiago

  结果显示系统为64位Redhat6.3 ,去Mysql官网(http://dev.mysql.com/downloads/mysql#downloads)下载相应的版本。

wget http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-devel-5.5.36-1.el6.x86_64.rpm
wget http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-client-5.5.36-1.el6.x86_64.rpm
wget http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-server-5.5.36-1.el6.x86_64.rpm

2、安装Mysql服务和客户端

rpm -ivh MySQL-server-5.5.-.el6.x86_64.rpm
[root@localhost mysql]# rpm -ivh MySQL-server-5.5.-.el6.x86_64.rpm
Preparing... ########################################### [%]
:MySQL-server ########################################### [%] PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost password 'new-password' Alternatively you can run:
/usr/bin/mysql_secure_installation which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers. See the manual for more instructions. Please report any problems at http://bugs.mysql.com/

[root@localhost mysql]# rpm -ivh MySQL-client-5.5.36-1.el6.x86_64.rpm
Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]

可能遇到的问题

1>如果出现类似:

file /usr/share/mysql/charsets/hebrew.xml from install of MySQL-server-5.5.-.el6.x86_64 conflicts with file from package mysql-libs-5.1.-.el6.x86_64
file /usr/share/mysql/charsets/hp8.xml from install of MySQL-server-5.5.-.el6.x86_64 conflicts with file from package mysql-libs-5.1.-.el6.x86_64
file /usr/share/mysql/charsets/keybcs2.xml from install of MySQL-server-5.5.-.el6.x86_64 conflicts with file from package mysql-libs-5.1.-.el6.x86_64
file /usr/share/mysql/charsets/koi8r.xml from install of MySQL-server-5.5.-.el6.x86_64 conflicts with file from package mysql-libs-5.1.-.el6.x86_64
file /usr/share/mysql/charsets/koi8u.xml from install of MySQL-server-5.5.-.el6.x86_64 conflicts with file from package mysql-libs-5.1.-.el6.x86_64
file /usr/share/mysql/charsets/latin1.xml from install of MySQL-server-5.5.-.el6.x86_64 conflicts with file from package mysql-libs-5.1.-.el6.x86_64

说明有包冲突,这时候要移除冲突的包,使用命令:

yum -y remove mysql-libs-5.1.*

2>如果移除时出现:

Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Existing lock /var/run/yum.pid: another copy is running as pid .

说明YUM正在更新,使用命令:

rm -f    /var/run/yum.pid

3、服务启动、停止、重新启动

[root@localhost usr]# service mysql start

[root@localhost usr]# service mysql stop

[root@localhost usr]# service mysql restart

4、修改root密码

[root@localhost bin]# mysqladmin -u root -p'root' password 'rockontrol'

5、常见问题

登录出现 Access denied for user 'root'@'localhost' (using password:YES)。解决步骤如下:

a:以root用户登录系统

b:看一下Mysql服务的状态 如果启动则杀掉进程 命令如下

[root@localhost ~]# /etc/init.d/mysql status
ERROR! MySQL is running but PID file could not be found
[root@localhost ~]# ps aux|grep mysql
root 0.0 0.0 ? S 6月16 : /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/localhost.localdomain.pid
mysql 0.0 2.7 ? Sl 6月16 : /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/localhost.localdomain.err --pid-file=/var/lib/mysql/localhost.localdomain.pid
root 0.0 0.0 pts/ S+ : : grep --color=auto mysql
[root@localhost ~]# kill
[root@localhost ~]# kill
[root@localhost ~]# kill

c:启动特权命令:mysqld_safe --skip-grant-tables &

d:在重新打开一个连接以普通用户命令进去   这时候就不需要在输入密码了

[root@localhost ~]# mysql -u root -p
Enter password:

直接回车就可以进去了   然后修改user表的密码就可以了

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Database changed
mysql> select host,user,password from user;
+-----------------------+------+-------------------------------------------+
| host | user | password |
+-----------------------+------+-------------------------------------------+
| localhost | root | *68A463BD53874E39A4D68117C03FB1A777EC9DA9 |
| localhost.localdomain | root | *68A463BD53874E39A4D68117C03FB1A777EC9DA9 |
| 127.0.0.1 | root | *68A463BD53874E39A4D68117C03FB1A777EC9DA9 |
| :: | root | *68A463BD53874E39A4D68117C03FB1A777EC9DA9 |
+-----------------------+------+-------------------------------------------+
rows in set (0.00 sec) mysql> update user set host='%' where host='localhost';
Query OK, row affected (0.00 sec)
Rows matched: Changed: Warnings: mysql> update user set password='';
Query OK, rows affected (0.00 sec)
Rows matched: Changed: Warnings:

这样就清空所有的密码了
e:这时候可以退出特权模式 重新启动Mysql服务  然后修改一下密码就可以了

SET PASSWORD=PASSWORD('');

Linux下Mysql安装的更多相关文章

  1. linux下MySQL安装登录及操作

    linux下MySQL安装登录及操作 二.安装Mysql 1.下载MySQL的安装文件 安装MySQL需要下面两个文件: MySQL-server-4.0.16-0.i386.rpm MySQL-cl ...

  2. Linux下MySQL安装和配置

    --Linux下MySQL安装和配置 ---------------------------2014/05/18 Linux下MySQL的配置和安装 本文的安装采用 rpm 包安装 1.首先在官网下载 ...

  3. Linux下Mysql安装(RPM安装)

    1. 首先检查机器里是否已经存在MySQL $ rpm -qa | grep mysql 2. 去官网下载相应的rpm包:https://dev.mysql.com/downloads/mysql/ ...

  4. Linux下MySQL安装及配置

    Linux下MySQL安装及配置 安装MySQL Ubuntu系统中,直接使用apt install的方式去安装MySQL的服务端和客户端,MySQL的客户端必须安装,否则无法通过命令连接并操作MyS ...

  5. linux 下 mysql安装和配置

    最近在学习R语言,看到R与数据库交互这一部分,就自己动手实践了一下,数据库选择的是mysql,主要记录下linux下怎么安装mysql. 网上的很多资料都有相关的文章,这里只是记录下自己安装过程中遇到 ...

  6. Linux下mysql安装过程

    到mysql官网下载mysql编译好的二进制安装包,在下载页面Select Platform:选项选择linux-generic,然后把页面拉到底部,64位系统下载Linux - Generic (g ...

  7. Linux下Mysql安装教程详解

    Linux下软件安装一般有三种方式:RPM包方式(通过Redhat 第三方包管理系统).二进制包和源码包.本篇主要介绍二进制包安装mysql数据库的方式. 如何获取二进制源码包 当然是到mysql官网 ...

  8. Linux下mysql安装记录

    1.MySQL下载路径:https://dev.mysql.com/downloads/ Linux下的安装步骤:http://www.runoob.com/linux/mysql-install-s ...

  9. linux下MySQL安装及设置

    转自:http://www.entage.net/1/viewspace-25420 1. 关于本文    本文将以MySQL 5.0.51为例,以CentOS 5为平台,讲述MySQL数据库的安装和 ...

  10. linux下mysql安装报错及修改密码登录等等

    1:下载 [root@localhost soft]# wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.19-linux-glibc ...

随机推荐

  1. 迭代接口的IEnumerator

    我们经常在工作中用到对List,Dictionary对象的Foreach遍历,取出每一项. 其实这个接口很简单,只有一个属性2个方法. [ComVisible(true), Guid("49 ...

  2. Opserver监控工具的使用

    Opserver监控工具的使用 Opserver是Stack Overflow的开源监控解决方案,由Stack Exchange发布,基于.NET框架构建.开源地址:https://github.co ...

  3. android图片拖动缩放

    这篇图片拖拽缩放也是我在项目中用到的,今天整理一下,将源码奉献给大家,希望对大家以后碰到相似的问题有帮助.android 大图片拖拽缩放 这篇就不做过多介绍了,直接上源码: public class ...

  4. Fluent NHibernate example

    http://www.codeproject.com/Articles/26466/Dependency-Injection-using-Spring-NET http://stackoverflow ...

  5. <s:iterator>各种遍历用法

    struts2<S:iterator>遍历map小结 1.MapAction.java import java.util.ArrayList;   import java.util.Has ...

  6. java获取class所在jar

    在类库的开发过程中,有些时候为了self-contain的原因,我们希望所有的资源都打包在jar中,但是有些工具好像无法支持从classpasth直接获取比如velocity的模板合并,此时我们就知道 ...

  7. 【GOF23设计模式】原型模式

    来源:http://www.bjsxt.com/ 一.[GOF23设计模式]_原型模式.prototype.浅复制.深复制.Cloneable接口  浅复制 package com.test.prot ...

  8. css三角形的实现

    实底三角形: <html> <head> <title></title> <style type="text/css"> ...

  9. Ajax基本知识

    1.创建xhr对象 var xmlhttp; if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari x ...

  10. SharePoint 使用PowerShell恢复误删的网站集

    在SharePoint网站集的使用中,我们很有可能会误删我们需要的网站集,SharePoint其实并没有把网站集删掉,只是放到了SPDeletedSite中,这样,我们还可以通过PowerShell找 ...