002. Centos7安装mysql5.5.37
- 下载cmake-2.8.12.2.tar.gz, 下载地址: https://pan.baidu.com/s/1qYtpX7m
- 下载mysql-5.5.37.tar.gz, 下载地址: http://pan.baidu.com/s/1miFcNP2
- 下载ncurses-5.9.tar.gz, 下载地址: http://pan.baidu.com/s/1kVDIXW7
(百度网盘的连接地址使用wget下载不了)
4. 将上面三个包, 传到服务器上, 并解压
[root@iZ25bdzgev8Z mysql-5.5.37]# tar xvf mysql-5.5.37.tar.gz
5. 进入cmake-2.8.12.2目录(如有报错请看文末)
[root@iZ25bdzgev8Z cmake-2.8.12.2]# ./configure
[root@iZ25bdzgev8Z cmake-2.8.12.2]# make && make install
6. 进入mysql-5.5.37目录
[root@iZ25bdzgev8Z ~]# cd mysql-5.5.37
[root@iZ25bdzgev8Z mysql-5.5.37]# cmake ./ (如有报错请看文末)
7. 解决完上面的报错后, 继续执行(如果没有报错, 此步骤可直接跳过)
[root@iZ25bdzgev8Z ncurses-5.9]# cd ..
[root@iZ25bdzgev8Z ~]# cd mysql-5.5.37
[root@iZ25bdzgev8Z mysql-5.5.37]#
[root@iZ25bdzgev8Z mysql-5.5.37]# rm -f CMakeCache.txt
因为刚才没有编译成功, 所以需要删除刚才编译生成的CmakeCache.txt文件, 否则过不去的, 然后重新cmake ./
[root@iZ25bdzgev8Z mysql-5.5.37]# cmake ./
8.开始安装, mysql默认将成功安装到/usr/local/mysql
[root@iZ25bdzgev8Z mysql-5.5.37]# make && make install
9. 在它安装的过程中创建一个mysql用户和mysql组
[root@iZ25bdzgev8Z ~]# groupadd mysql
[root@iZ25bdzgev8Z ~]# useradd -r -g mysql mysql
[root@iZ25bdzgev8Z ~]# chown -R mysql.mysql /usr/local/mysql
这个目录,如果没有安装成功, 是不可以操作/usr/local/mysql目录的
10. 启动mysql
[root@iZ25bdzgev8Z ~]# /usr/local/mysql/bin/mysqld_safe --user=mysql
11. 注册mysql服务, 设置开机自动启动
复制配置文件到etc下:
[root@iZ25bdzgev8Z ~]# cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
复制mysql启动文件到init.d目录下, 并命名为mysql
[root@iZ25bdzgev8Z ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
[root@iZ25bdzgev8Z ~]# chmod +x /etc/init.d/mysql
[root@iZ25bdzgev8Z ~]# /sbin/chkconfig --add mysql
添加系统变量:
[root@iZ25bdzgev8Z ~]# vi /etc/profile #修改profile文件, 下次重启也能生效
export PATH=$PATH:/usr/local/mysql/bin # 在配置文件中加入此行配置
[root@iZ25bdzgev8Z ~]# source /etc/profile
修改 .bashrc 文件使在当前用户 shell 下生效
# vi /root/.bashrc
在里面加入:
export
PATH=$PATH:/usr/local/mysql/bin
修改这个文件之后同样也需要使用 source使配置文件生效.
启动mysql服务:
[root@iZ25bdzgev8Z
~]# service mysql start (可能会报错了)
Starting
MySQL...The server quit without updating PID file [FAILED]cal/mysql/data/iZ25bdzgev8Z.pid).
//重新启动服务
[root@iZ25bdzgev8Z
~]# /usr/local/mysql/scripts/mysql_install_db --user=mysql
--basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
Installing MySQL system tables...
尝试连接:
[root@iZ25bdzgev8Z ~]# /usr/local/mysql/bin/mysql -u root
-p
12. 登录mysql
[root@iZ25bdzgev8Z
~]# /usr/local/mysql/bin/mysql -u root -p
Enter
password:
ERROR
2002 (HY000): Can't connect to local MySQL server through socket
'/tmp/mysql.sock' (2) #没有mysql.sock文件
[root@iZ25bdzgev8Z
/]# killall mysqld
[root@iZ25bdzgev8Z
/]# killall mysql #杀死所有和mysql相关的进程
[root@iZ25bdzgev8Z
~]# ls /tmp/mysql
ls: cannot
access /tmp/mysql: No such file or directory
[root@iZ25bdzgev8Z
~]# find / -name mysql.sock #找一找
/var/lib/mysql/mysql.sock
修改my.cnf配置文件, 后重启mysql, 然后重新登录即可
[root@iZ25bdzgev8Z ~]# vi /etc/my.cnf
[client]
#password =
your_password
port = 3306
#socket
= /tmp/mysql.sock
socket
= /var/lib/mysql/mysql.sock #如果这个不行, 还需要将上面一行给解开注释. . .
[root@iZ25bdzgev8Z
/]# netstat -tnulp | grep 3306 #过滤下3306, 此时应该没有任何信息
[root@iZ25bdzgev8Z
/]# /etc/rc.d/init.d/mysql start
Starting MySQL..
[ OK ]
#此时再过滤3306应该有数据了
13. 使用mysql登录吧
[root@iZ25bdzgev8Z /]# mysql
Welcome to the MariaDB
monitor. Commands end with ; or \g.
Your MySQL connection id
is 1
Server version: 5.5.37-log
Source distribution
Copyright (c) 2000, 2016,
Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for
help. Type '\c' to clear the current input statement.
MySQL [(none)]> exit
Bye
错误及其解决方案:
1. 在安装cmake执行到, make时候报出以下错误:
e: *** No targets specified and no makefile
found. Stop.
解决方案:
这是没有安装编译环境所致, 联网安装gcc
yum install gcc gcc-c++ autoconf automake
2. 安装mysql 5.5.37时候的错误提示:
Curses library not
found. Please install
appropriate package,
remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is
libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
cmake/readline.cmake:127 (FIND_CURSES)
cmake/readline.cmake:217
(MYSQL_USE_BUNDLED_LIBEDIT)
CMakeLists.txt:355 (MYSQL_CHECK_READLINE)
ncurses是字符终端下屏幕控制的基本库,很多新开发的程序已经不再使用,但要编译一些老的程序,还是会经常碰到,解决这个问题就是安装一下Curses即可
[root@iZ25bdzgev8Z ~]# tar xvf
ncurses-5.9.tar.gz
[root@iZ25bdzgev8Z ~]# cd ncurses-5.9
[root@iZ25bdzgev8Z ncurses-5.9]#
./configure && make && make install
3. 登录错误故障解决:
[root@iZ25bdzgev8Z ~]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@iZ25bdzgev8Z ~]# netstat -ano | grep 3306 #
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN off (0.00/0/0)
[root@iZ25bdzgev8Z ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.37-log Source distribution
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]> use mysql;
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
#因为mysql数据库的user表里,存在用户名为空的账户即匿名账户,导致登录的时候是虽然用的是root,但实际是匿名登录的
MySQL [(none)]> exit
Bye
解决方案:
[root@iZ25bdzgev8Z ~]# service mysql stop #停止msyql
Shutting down MySQL. [ OK ]
[root@iZ25bdzgev8Z ~]# mysqld_safe --skip-grant-table
161228 09:23:52 mysqld_safe Logging to '/var/lib/mysql/iZ25bdzgev8Z.err'.
161228 09:23:52 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
#新开一个连接
[root@iZ25bdzgev8Z ~]# mysql -u root mysql
. . .
MariaDB [mysql]> delete from user where USER='';
Query OK, 0 rows affected (0.00 sec)
MariaDB [mysql]> show databases;
. . .
MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> show databases;
. . .
MariaDB [(none)]> use mysql;
Database changed
MariaDB [mysql]> select host , user,password from user;
+-----------+------+-------------------------------------------+
| host | user | password |
+-----------+------+-------------------------------------------+
| localhost | root | *C722458C25A26EA653682196537D713A5AE439F8 |
| 127.0.0.1 | root | *C722458C25A26EA653682196537D713A5AE439F8 |
| ::1 | root | *C722458C25A26EA653682196537D713A5AE439F8 |
+-----------+------+-------------------------------------------+
3 rows in set (0.00 sec)
002. Centos7安装mysql5.5.37的更多相关文章
- Centos7 安装 MySQL5.7
Centos7 安装 MySQL5.7 一.环境介绍 1.安装包版本介绍 MySQL 有三种安装方式:RPM安装.二进制包安装.源码包安装.我们这篇文章以二进制方式安装MySQL 软件名称 版本 系统 ...
- CentOS 6.9上安装mysql-5.6.37
CentOS 6.9上安装mysql-5.6.37 1.准备数据存放的文件系统 新建一个逻辑卷,并将其挂载至特定目录即可.这里不再给出过程. 这里假设其逻辑卷的挂载目录为/data,而后需要创建/da ...
- centos7安装mysql5.7.19及配置远程连接
centos7安装mysql5.7.19及配置远程连接------https://blog.csdn.net/Lh19931122/article/details/77996213
- Linux学习第三步(Centos7安装mysql5.7数据库)
版本:mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar 前言:在linux下安装mysql不如windows下面那么简单,但是也不是很难.本文向大家讲解了如何在Cent ...
- Centos7安装mysql-5.7.19
Centos7安装Mysql 一 mysql下载 地址: https://dev.mysql.com/downloads/mysql/#downloads 二 在centos7上创建安装文件存放.解压 ...
- Centos7安装Mysql5.7方法总结 - 实操手册
Centos7.x版本下针对Mysql的安装和使用多少跟之前的Centos6之前版本有所不同的,废话就不多赘述了,下面介绍下在centos7.x环境里安装mysql5.7的几种方法:一.yum方式安装 ...
- centos7安装mysql5.7修改设置密码策略
centos7操作系统在安装mysql5.7社区版之后会有默认密码,通过grep命令在mysqld.log文件中即可找到,如下所示: 标识位置即在初始化安装时mysql的默认密码,然后通过mysql ...
- centos7安装MySQL5.7无法设置密码问题
前言 在使用centos7系统yum方式安装MySQL5.7后 不知道默认密码是多少 知道后没办法修改? 一.找到MySQL密码 service mysqld start vim /var/log/ ...
- CentOS7安装MySQL5.7以及修改密码
CentOS7安装mysql [root@bd005 ~]# wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch. ...
随机推荐
- 涵涵和爸爸习惯养成进度表(三)(June 25 - )
规则说明 23天内,没有哭脸,不超过三个无表情脸,可以给一个奖励(动画书等) 涵涵违反规则,在爸爸和妈妈都同意的情况下,可以给无表情脸 爸爸违反规则,在妈妈和涵涵都同意的情况下,可以给无表情脸 获奖记 ...
- iOS开发笔记1:[转]导航栏里的"Back"按钮显示不出来
最近项目中遇到一个问题,push过去的ViewController的Nav上面没有返回按钮,遂搜索资料,找到了以下文档.经测试i,问题解决. 原文地址:http://www.cnblogs.com/s ...
- 【JavaScript】之【Object】
见代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF- ...
- Socket通信代码(原理)
1.运行环境:NetBeans IDE 6.0.1 2.说明:先运行服务器端,再运行客户端. 3.服务器端代码: 新建java类Test import java.net.*; import java. ...
- K-近邻算法
废话不多说,直接放码过来. from numpy import * import operator def createDataSet () : group = array([[,],[,0.1]]) ...
- BZOJ 2743 树状数组
不能用分块. #include <bits/stdc++.h> using namespace std; ; struct Info{int l,r,Id;}Q[Maxn]; int a[ ...
- Integer to Roman -- LeetCode 012
Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 t ...
- sql 删除表格delete drop truncate 区别(转)
(1) DELETE语句执行删除的过程是每次从表中删除一行,并且同时将该行的删除操作作为事务记录在日志中保存以便进行进行回滚操作.TRUNCATE TABLE 则一次性地从表中删除所有的数据并不把 ...
- Excel 导入 Sql Server出错——“文本被截断,或者一个或多个字符在目标代码页中没有匹配项”错误的解决
有人说应该先转成Access, 再转到Sql Server. 其实用处并不大, 要截断的还是被截断了. 原因是,SQL Server的导入导出为了确定数据表的字段类型,取excel文件的前8行来判别. ...
- 07——为多态基类声明为virtual析构函数
当基类确定被继承的时候,析构函数声明为virtual是必须的 当返回的派生类的指针或引用的时候,调用析构函数容易发生内存泄漏 当基类作为抽象类使用,声明pure virtual析构函数 析构函数的顺序 ...