1。 下载mysql
(1) 下载镜像地址:http://mirrors.sohu.com/mysql/
(2) 选择版本:
MySQL-client-5.5.45-1.linux2.6.x86_64.rpm
MySQL-devel-5.5.45-1.linux2.6.x86_64.rpm
MySQL-server-5.5.45-1.linux2.6.x86_64.rpm
2. 上传到linux服务器 xftp
3. 开始安装
(1) 先看看服务器上是否安装了 mysql 或 mariadb
命令:rpm -qa | grep mysql
rpm -qa | grep mariadb
如果有杀之:rpm -e --nodeps mysql-libs-5.1.73-3.el6_5.x86_64
(2) rpm安装
rpm -ivh MySQL-server-5.5.45-1.linux2.6.x86_64.rpm
rpm -ivh MySQL-client-5.5.45-1.linux2.6.x86_64.rpm
rpm -ivh MySQL-devel-5.5.45-1.linux2.6.x86_64.rpm
4. MYSQL目录赋权限: chown -R mysql:mysql /var/lib/mysql 否则会提示 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' 之类的错 误
5. 重置mysql密码
(1) ps -ef | grep -i mysql 查看mysql 进程 确定 安装目录
root 3873 1 /usr/bin/mysqld_safe --skip-grant-tables 0 10:14 pts/0 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/master.hadoop.pid
(2) /usr/bin/mysqld_safe --skip-grant-tables 免密码启动 ----然后在另开一个窗口 输入 “mysql” 命令
[root@master ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.45 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
(3)修改 mysql 数据库 user表 root 用户密码
UPDATE user SET Password=PASSWORD('root') where USER='root';
(4) 退出重新启动 然后 用密码登录