单实例MySQL安装

1、建立账号

[[email protected] ~]# groupadd mysql

[[email protected] ~]# useradd -s /sbin/nologin -g mysql -Mmysql

useradd参数说明:

-s/sbin/nologin 表示禁止该用户登录

-gmysql 指定属于mysql组

-M表示不创建用户家目录

2、配置安装环境

创建目录并授权:

[[email protected] ~]# mkdir /home/tools

[[email protected] ~]# mkdir -p /usr/local/mysql

[[email protected] ~]#mkdir -p /data/mysql

[[email protected] ~]#chown -R mysql.mysql /usr/local/mysql/

[[email protected] ~]#chown -R mysql:mysql /data/mysql

安装系统软件包:

[[email protected] ~]# yum install gcc gcc-c++ make cmakencurses-devel bison perl

配置解析:

[[email protected] ~]# hostname

opsedu

[[email protected] ~]# vim /etc/hosts

10.47.129.177 opsedu        添加一条

安装cmake:

[[email protected] ~]# rpm -qa | grep cmake   使用系统自带cmake,编译时,有时候会报错

cmake-2.8.12.2-4.el6.x86_64         版本2.8.12

[[email protected] ~]# yum remove cmake –y

[[email protected] ~]# cd /home/tools

[[email protected] tools]# wget https://cmake.org/files/v2.8/cmake-2.8.12.tar.gz

[[email protected] tools]# tar -zxf cmake-2.8.12.tar.gz

[[email protected] tools]# cd cmake-2.8.12

[[email protected] cmake-2.8.12]# ./configure

[[email protected] cmake-2.8.12]# gmake

[[email protected] cmake-2.8.12]# gmake install

[[email protected] cmake-2.8.12]# cd ..

[[email protected] tools]# cmake --version

cmake version 2.8.12

3、安装mysql

[[email protected] tools]# wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.37.tar.gz

[[email protected] tools]# tar -zxf mysql-5.5.37.tar.gz

[[email protected] tools]# cd mysql-5.5.37

[[email protected] mysql-5.5.37]# cmake \

> -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ \

> -DMYSQL_DATADIR=/data/mysql \

> -DMYSQL_TCP_PORT=3306 \

> -DDEFAULT_CHARSET=utf8 \

> -DDEFAULT_COLLATION=utf8_general_ci \

> -DEXTRA_CHARSETS=all \

> -DENABLED_LOCAL_INFILE=ON \

> -DWITH_INNOBASE_STORAGE_ENGINE=1 \

> -DWITH_FEDERATED_STORAGE_ENGINE=1 \

> -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

> -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \

> -DWITHOUT_PARTITION_STORAGE_ENGINE=1 \

> -DWITH_FAST_MUTEXES=1 \

> -DWITH_ZLIB=bundled \

> -DENABLED_LOCAL_INFILE=1 \

> -DWITH_READLINE=1 \

> -DWITH_EMBEDDED_SERVER=1 \

> -DWITH_DEBUG=0 \

> -DMYSQL_UNIX_ADDR=/tmp/mysql.sock

编译安装:

[[email protected] mysql-5.5.37]# make

[[email protected] mysql-5.5.37]# make install

拷贝配置:

[[email protected] mysql-5.5.37]# ll support-files/*.cnf

-rw-r--r-- 1 root root  4671 Jan 29 15:11 support-files/my-huge.cnf

-rw-r--r-- 1 root root 19759 Jan 29 15:11support-files/my-innodb-heavy-4G.cnf

-rw-r--r-- 1 root root  4645 Jan 29 15:11 support-files/my-large.cnf

-rw-r--r-- 1 root root  4656 Jan 29 15:11 support-files/my-medium.cnf

-rw-r--r-- 1 root root  2820 Jan 29 15:11 support-files/my-small.cnf

[[email protected] mysql-5.5.37]# /bin/cpsupport-files/my-huge.cnf /etc/my.cnf

创建mysql数据库文件:

[[email protected] mysql-5.5.37]#/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql--datadir=/data/mysql --user=mysql

启动mysql:

[[email protected] mysql-5.5.37]#  /usr/local/mysql/bin/mysqld_safe --user=mysql&

[[email protected] mysql-5.5.37]# netstat -lnt|grep 3306

tcp       0     0 0.0.0.0:3306          0.0.0.0:*               LISTEN

配置mysql:

[[email protected] ~]# echo ‘exportPATH=/usr/local/mysql/bin:$PATH‘ >>/etc/profile

[[email protected] ~]# source /etc/profile

配置mysql开机启动:

[[email protected] mysql-5.5.37]# cpsupport-files/mysql.server /etc/init.d/mysqld

[[email protected] mysql-5.5.37]# chmod 700 /etc/init.d/mysqld

[[email protected] ~]# chkconfig --add mysqld

[[email protected] ~]# chkconfig mysqld on

为mysql root用户增加密码:

[[email protected] ~]# mysqladmin -uroot password‘q.123456‘

安装之后的选项:

[[email protected] ~]# mysql -uroot -pq.123456

mysql> select user,host,password from mysql.user;

+------+-----------+-------------------------------------------+

| user | host     | password                                 |

+------+-----------+-------------------------------------------+

| root | localhost |*026FC8CD6C3B58F3C3566D83F8189585C9F3F292 |

| root | opsedu   |                                           |

| root | 127.0.0.1 |                                           |

| root | ::1      |                                           |

|      |localhost |                                           |

|      |opsedu    |                                           |

+------+-----------+-------------------------------------------+

6 rows in set (0.00 sec)

删除无用的账号:

mysql> delete from mysql.user where user=‘ ‘;

Query OK, 2 rows affected (0.00 sec)

mysql> delete from mysql.user where password=‘ ‘;

Query OK, 3 rows affected (0.00 sec)

mysql> select user,host,password from mysql.user;

+------+-----------+-------------------------------------------+

| user | host     | password                                  |

+------+-----------+-------------------------------------------+

| root | localhost |*026FC8CD6C3B58F3C3566D83F8189585C9F3F292 |

+------+-----------+-------------------------------------------+

1 row in set (0.00 sec)

时间: 2024-11-12 11:07:05

单实例MySQL安装的相关文章

centos6.5安装单实例mysql

mysql官网下载地址:http://downloads.mysql.com/archives/community/ 选择x64源码安装包进行下载: 将安装文件放在/usr/local/src/下 卸载和删除mysql原有的相关内容: userdel -r mysql groudel mysql find / -name "mysql" -exec rm -rf {} \; 新建mysql用户.用户组: groupadd mysql useradd -s /sbin/nologin -

安装lamp之 一键安装单实例mysql

#!/bin/sh #一键安装单实例mysql #xiaogao 20190921 #创建相关mysql用户 groupadd mysql useradd -s /sbin/nologin -g mysql -M mysql tail -1 /etc/passwd #安装mysql依赖库 yum -y install ncurses-devel #开启安装mysql,记得先上传安装包到/home/lvnian/tools/ cd /home/lvnian/tools/ tar zxf mysql

单实例数据库安装脚本

安装脚本 1.1_preusers.sh #!/bin/bash #Purpose:Create 3 groups named 'oinstall','dba','oper', plus 1 users named 'oracle'. #Also setting the Environment #variable for oracle user. #Usage:Log on as the superuser('root'),and then execute the command:#./1pre

MySQL 5.5单实例 编译安装

1.建立MySQL账号 首先以root登录到Linux,然后执行如下命令创建MySQL组及用户   [[email protected] home]# groupadd mysql   [[email protected] home]# useradd -s /sbin/nologin -g mysql -M mysql   [[email protected] home]# tail -1 /etc/passwd   feitian:x:811:811::/home/mysql:/sbin/n

Mysql单实例的安装配置指南

实验环境: 操作系统:CentOS 6.8 虚拟机:VMware  数据库:mysql-5.1.62.tar.gz 安装步骤: #wget  http://soft.vpser.net/datebase/mysql/mysql-5.1.62.tar.gz #tar  zxf mysql-5.1.62.tar.gz [[email protected] mysql-5.1.62]#./configure  \ --prefix=/usr/local/mysql \ --with-unix-sock

Linux环境下安装单实例MySQL 5.7

一.安装环境 1.操作系统版本:CentOS 7.5 2.MySQL版本:5.7.22(社区版) 3.MySQL安装包:mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz 二.安装步骤 1.检查系统中是否安装了其他版本的MySQL(root用户) 首先检查系统中是否安装了其他版本的MySQL,使用以下命令进行检查: yum list installed | grep mysql yum list installed | grep mariadb MariaDB数

同主机单实例MySQL跨库同步指定表

需求: 同一主机同实例MySQL有A和B两个库,现在需实现test1库中表host和test2库中表host插入.删除.更新单向同步.(table01与table02具有相同表结构) 解决方案: 可以使用触发器实现,举例如下: 1.创建模拟环境 create database test1; use test1 CREATE TABLE `host` ( `id` tinyint(4) NOT NULL AUTO_INCREMENT, `host` varchar(20) NOT NULL, `p

mysql单实例的安装和简单配置(5.1.*版本)

1.创建mysql帐号 useradd -M -s /sbin/nologin -u 49 mysql 执行过程: [[email protected] ~]# useradd -M -s /sbin/nologin -u 49mysql [[email protected] ~]# cat /etc/passwd | grep mysql mysql:x:49:500::/home/mysql:/sbin/nologin 参数说明: -M 不创建mysql家目录 -s 指定mysql登录的sh

MySQL第01课- CentOS + 单实例MySql编译安装总结

2016年2月,从oracle转向MySql ,碰上几个坑,特此记录 总结 1.注意环境变量.配置文件,操作过程不能出错 2.相比rpm方式安装,编译安装方式可以指定安装路径,再说安装是简单活,将来安装最新版数据库,会看文档,学里面的知识更重要 3.系统管理员操作数据库一定要小心,重要操作应三思而后行 ----------------------------------------- 1.注意:第一步要检查是否有安装过mysql,有的话要干掉,否则最后启动服务不成功 [root@fox ~]#