http://forrest-lv.iteye.com/blog/2260703
安装前,需要检查是否已经有mysql服务进程,是否已经装过mysql; 这点很重要,我之前安装CentOS的同时,安装了mysql相关的东东,导致后面新安装mysql时,安装、启动时报了一堆的错。
例如:
Ignoring user change to 'laolv' because the user was set to 'mysql' earlier on the command line
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
mysql Unknown error 1045
参考网址
http://www.cnblogs.com/kreo/p/4392090.html
http://blog.csdn.net/chenggong2dm/article/details/6568862
http://tieba.baidu.com/p/3881791613
http://bbs.chinaunix.net/thread-3967681-1-1.html
一、卸载
卸载前关闭MySQL服务:
[laolv@centos65 Desktop]$ ps -ef | grep mysql
[laolv@centos65 Desktop]$ chkconfig --list | grep -i mysql
因为没有将mysql做成服务,那么查出进程号,直接
kill -9 pid
查找机器是否安装mysql,如果安装过则卸载
[root@centos65 ~]# rpm -qa | grep -i mysql
[root@centos65 ~]# rpm -ev mysql-libs-5.1.71-1.el6.x86_64 --force
rpm: only installation, upgrading, rmsource and rmspec may be forced
[root@centos65 ~]# rpm -ev mysql-libs-5.1.71-1.el6.x86_64 --nodeps
warning: /etc/my.cnf saved as /etc/my.cnf.rpmsave
删除mysql用户
[root@DB-Server ~]# id mysql
uid=101(mysql) gid=501(mysql) groups=501(mysql) context=root:system_r:unconfined_t:SystemLow-SystemHigh
[root@DB-Server ~]# userdel mysql
删除MySQL对应的文件夹:
[root@centos65 ~]# find / -name mysql
/home/mysql
/var/spool/mail/mysql
/var/lib/mysql
/var/lib/mysql/mysql
/mnt/hgfs/sharefiles/apache-hive-1.3.0-SNAPSHOT-bin/scripts/metastore/upgrade/mysql
/opt/hive/apache-hive-1.3.0-SNAPSHOT-bin/scripts/metastore/upgrade/mysql
/opt/softwares/mysql-5.7.9-linux-glibc2.5-x86_64/include/mysql
/opt/softwares/mysql-5.7.9-linux-glibc2.5-x86_64/bin/mysql
[root@centos65 ~]# rm -rf /var/lib/mysql/
[root@centos65 ~]# rm -rf /home/mysql/
[root@centos65 ~]# rm -rf /var/spool/mail/mysql
重启操作系统
二、安装
一般安装都是先创建 用户:组 mysql:mysql ,例如网址一
我这儿使用已经存在的用户:组 laolv:laolv
需要注意:
glibc版本的Mysql,不是编译版的,是直接编译好的,相当于windows的绿色版
CentOS默认yum源已经没有mysql-server了.而用mariadb代替,而2个数据库冲突,所以要安装mysql,要先卸载mariadb
我的机器上是没有mariadb的
[root@centos65 ~]# find / -name mariadb
[root@centos65 ~]# ps -ef | grep mariadb
root 4632 4475 0 16:32 pts/0 00:00:00 grep mariadb
[root@centos65 ~]# rpm -qa | grep -i mariadb
[root@centos65 ~]#
[laolv@centos65 softwares]$ mv mysql-5.7.9-linux-glibc2.5-x86_64 mysql_5_7_9
[laolv@centos65 softwares]$ cd mysql_5_7_9
需要注意:
参考http://tieba.baidu.com/p/3881791613
mysql_install_db 已经不再推荐使用了,建议改成 mysqld --initialize 完成实例初始化。
改成 mysqld --initialize 后,如果 datadir 指向的目标目录下已经有数据文件,则会有类似提示:
[ERROR] --initialize specified but the data directory has files in it. Aborting.
另外,在初始化时如果加上 --initialize-insecure ,则会创建空密码的 root@localhost 账号,否则会创建带密码的 root@localhost 账号,密码直接写在 log-error 日志文件中(在5.6版本中是放在 ~/.mysql_secret 文件里,更加隐蔽,不熟悉的话可能会无所适从)
1.安装Mysql/初始化mysql数据库
[laolv@centos65 mysql_5_7_9]$ mkdir data
[laolv@centos65 mysql_5_7_9]$ ./bin/mysqld --user=laolv --basedir=/opt/softwares/mysql_5_7_9 --datadir=/opt/softwares/mysql_5_7_9/data --initialize-insecure
2015-11-30T17:01:03.346374Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2015-11-30T17:01:03.359032Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
2015-11-30T17:01:03.359397Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-11-30T17:01:03.788602Z 0 [Warning] InnoDB: New log files created, LSN=45790
2015-11-30T17:01:03.859671Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2015-11-30T17:01:03.899396Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: f0ac2cdd-9783-11e5-8670-000c292ec6d6.
2015-11-30T17:01:03.901991Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2015-11-30T17:01:03.903051Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
[laolv@centos65 mysql_5_7_9]$
2.开启mysql
(
注意 bin/mysqld_safe --user=laolv &
我没有在后面带& , &表示在后台运行,ctrl-c结束不掉进程的,需要kill -9 pid 结束进程的
)
[laolv@centos65 mysql_5_7_9]$ bin/mysqld_safe --user=laolv
151130 17:12:11 mysqld_safe Logging to '/opt/softwares/mysql_5_7_9/data/centos65.err'.
151130 17:12:12 mysqld_safe Starting mysqld daemon with databases from /opt/softwares/mysql_5_7_9/data
至此,mysql安装成功。
因为mysq处在运行状态,不要ctrl-c,再开一个ssh窗口,进行登录验证之类的..
[laolv@centos65 Desktop]$ ps -ef | grep mysql
laolv 8377 5342 0 17:12 pts/0 00:00:00 /bin/sh bin/mysqld_safe --user=laolv
laolv 8459 8377 0 17:12 pts/0 00:00:00 /opt/softwares/mysql_5_7_9/bin/mysqld --basedir=/opt/softwares/mysql_5_7_9 --datadir=/opt/softwares/mysql_5_7_9/data --plugin-dir=/opt/softwares/mysql_5_7_9/lib/plugin --user=laolv --log-error=/opt/softwares/mysql_5_7_9/data/centos65.err --pid-file=/opt/softwares/mysql_5_7_9/data/centos65.pid
laolv 8837 8823 0 17:15 pts/1 00:00:00 grep mysql
[laolv@centos65 Desktop]$ lsof -i:3306
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysqld 8459 laolv 20u IPv6 70640 0t0 TCP *:mysql (LISTEN)
[laolv@centos65 Desktop]$
3.为mysql的root用户添加密码
[laolv@centos65 Desktop]$ vi ~/.bash_profile
MYSQL_HOME=/opt/softwares/mysql_5_7_9
export MYSQL_HOME
PATH=$MYSQL_HOME/bin:$HIVE_HOME/bin:$HOME/bin:$PROTOBUF_HOME/bin:$JAVA_HOME/bin:$MAVEN_HOME/bin:$ANT_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$CMAKE_HOME/bin:$PATH
export PATH
[laolv@centos65 Desktop]$ su - laolv
密码:
[laolv@centos65 ~]$ which mysql
/opt/softwares/mysql_5_7_9/bin/mysql
[laolv@centos65 ~]$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.9 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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>
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.03 sec)
mysql> set password = password('forrest');
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> exit
Bye
[laolv@centos65 ~]$ mysql -uroot -p
Enter password:
此时需要输入密码了
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
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> show tables;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| engine_cost |
4. 关闭mysql
#关闭mysql
mysqladmin shutdown
#或
m
mysqladmin -uroot -p shutdown
mysql> exit
Bye
[laolv@centos65 ~]$ mysqladmin -uroot -p shutdown
Enter password:
[laolv@centos65 ~]$ ps -ef | grep mysql
laolv 11656 9533 0 17:44 pts/1 00:00:00 grep mysql
[laolv@centos65 ~]$
5. 今后开启mysql
不再需要初始化了,直接
[laolv@centos65 mysql_5_7_9]$ bin/mysqld_safe --user=laolv
151130 17:46:41 mysqld_safe Logging to '/opt/softwares/mysql_5_7_9/data/centos65.err'.
151130 17:46:41 mysqld_safe Starting mysqld daemon with databases from /opt/softwares/mysql_5_7_9/data
另开终端
[laolv@centos65 ~]$ ps -ef | grep mysql
laolv 11815 5342 0 17:46 pts/0 00:00:00 /bin/sh bin/mysqld_safe --user=laolv
laolv 11895 11815 6 17:46 pts/0 00:00:00 /opt/softwares/mysql_5_7_9/bin/mysqld --basedir=/opt/softwares/mysql_5_7_9 --datadir=/opt/softwares/mysql_5_7_9/data --plugin-dir=/opt/softwares/mysql_5_7_9/lib/plugin --user=laolv --log-error=/opt/softwares/mysql_5_7_9/data/centos65.err --pid-file=/opt/softwares/mysql_5_7_9/data/centos65.pid
laolv 11932 9533 0 17:46 pts/1 00:00:00 grep mysql
[laolv@centos65 ~]$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.9 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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> show database;
相关推荐
Centos6.5升级openssh-9.1p1包括32位和9.3版本的63位的全部rpm包,附带telnet客户端的rpm包 32位: openssh-9.1p1-1.el6.i386.rpm openssh-clients-9.1p1-1.el6.i386.rpm openssh-server-9.1p1-1.el6.i386.rpm ...
CentOS-6.5-i386-bin-DVD1.iso 下载地址百度云的下载连接。
CentOS-6.5-i386-minimalCentOS-6.5-i386-minimalCentOS-6.5-i386-minimal
MySQL安装后,建议执行`mysql_secure_installation`脚本来增强安全性: ``` /usr/bin/mysql_secure_installation ``` 在这个脚本中,你可以设置root用户的密码、删除匿名用户、禁止root远程登录以及删除测试数据库。...
centOS 6.5 安装 mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
Txt中包含 CentOS-6.5-x86_64-bin-DVD1 和 CentOS-6.5-x86_64-bin-DVD2 的官网下载地址 和 百度网盘下载地址
这个特定的压缩包文件 "centos6.5-hadoop-2.6.4.tar.gz" 是为在CentOS 6.5操作系统上安装Hadoop 2.6.4版本准备的。本文将详细讲解如何在CentOS 6.5系统中安装和配置Hadoop,以及Hadoop的基本工作原理。 首先,我们...
标题“centos6.5-hadoop-2.6.0-cdh5.9.0-nativelib”提及的是一个专为64位CentOS 6.5操作系统编译的Hadoop 2.6.0 CDH 5.9.0的本地库(nativelib)打包文件。这个压缩包包含了运行Hadoop在CentOS环境下所需的本机库,...
在 CentOS 6.5 的 64 位环境下安装 MySQL 5.7.19 通过 RPM 包的步骤如下: 首先,你需要确保系统已经准备就绪,包括更新系统到最新版本并安装必要的依赖。接下来,按照以下详细步骤进行操作: 1. **下载 RPM 包**...
centos6.5 iso 文件。
在 CentOS 6.5 上安装并配置 MySQL 5.5 是一项常见的任务,尤其是对于那些希望在服务器环境中部署稳定、可靠的数据库服务的系统管理员来说。本文将详细介绍如何在 CentOS 6.5 系统上安装 MySQL 5.5,并进行必要的...
CentOs6.5镜像源
- **64位**: [CentOS-6.5-x86_64-bin-DVD1.iso](http://mirror.centos.org/centos/6.5/isos/x86_64/CentOS-6.5-x86_64-bin-DVD1to2.torrent) #### 三、安装步骤 **1. 引导安装** - 插入CentOS 6.5安装光盘,启动...
### CentOS-6.5-i386-bin-DVD1.iso 相关知识点 #### 一、CentOS 6.5 简介 CentOS-6.5-i386-bin-DVD1.iso 是一个基于Red Hat Enterprise Linux (RHEL) 6.5 版本的发行版,它为用户提供了稳定、可靠且免费的企业级...
VMware10 安装并配置 CentOS-6.5-x86_64-bin-DVD1 VMware10 安装并配置 CentOS-6.5-x86_64-bin-DVD1 是一个详细的安装指南,旨在指导用户在 VMware10 中安装并配置 CentOS-6.5-x86_64-bin-DVD1 系统。该指南涵盖了...
在本教程中,我们将探讨如何在 CentOS6.5 和 Red Hat Enterprise Linux 6.5(RHEL6.5)环境下,通过源码编译方式安装 Keepalived 的 1.2.7 版本。 首先,了解 Keepalived 的功能至关重要。Keepalived 是 LVS(Linux...
centos6.5 minimal 安装包,linux系统,最小安装
在本文中,我们将详细探讨如何在CentOS 6.5系统上安装MySQL 5.6。这个过程涉及多个步骤,包括检查系统环境、删除遗留的服务和文件、安装必要的软件包、下载和配置MySQL源代码以及最后的安装和配置。让我们逐步了解每...
CentOS6.5 安装 MySQL5.5.37 详解 在本文中,我们将详细介绍如何在 CentOS6.5 操作系统上安装 MySQL5.5.37。由于 MySQL 是一个非常流行的关系型数据库管理系统,因此了解如何安装和配置 MySQL 是非常重要的。 卸载...
CentOS 7 安装 MySQL