linux_6.8编译安装mysql_5.5.32

  1. 安装说明
  1. 本次安装操作系统版本

[root@mysql_5 ~]# cat /etc/redhat-release

Red Hat Enterprise Linux Server release 6.8 (Santiago)

[root@mysql_5 ~]# uname -r

2.6.32-642.el6.x86_64

[root@mysql_5 ~]# uname -m

x86_64

  1. 安装mysql版本

[root@mysql_5 ~]# ls /software/

cmake-2.8.8.tar.gz  mysql-5.5.32.tar.gz

  1. 安装方法

本次安装采用cmake编译安装。

  1. 安装前准备
  1. 安装前检查

[root@mysql_5 ~]# rpm -qa|grep mysql

mysql-libs-5.1.73-7.el6.x86_64

  1. 删除已安装的mysql包

[root@mysql_5 ~]# rpm -e mysql-libs-5.1.73-7.el6.x86_64 --nodeps

[root@mysql_5 ~]# rpm -qa|grep mysql

[root@mysql_5 ~]#

 

  1. 安装
  1. 编译安装cmake
  1. 安装cmake所需要的gcc包

[root@mysql_5 ~]# mount /dev/cdrom /mnt/cdrom

[root@mysql_5 ~]# yum install gcc* -y

 

  1. 编译安装cmake

[root@mysql_5 ~]# cd /software/

[root@mysql_5 software]# ls

cmake-2.8.8.tar.gz  mysql-5.5.32.tar.gz

[root@mysql_5 software]# tar xf cmake-2.8.8.tar.gz

[root@mysql_5 software]# cd cmake-2.8.8

[root@mysql_5 cmake-2.8.8]# ./configure

[root@mysql_5 cmake-2.8.8]# gmake

[root@mysql_5 cmake-2.8.8]# echo $?

0

[root@mysql_5 cmake-2.8.8]# gmake install

  1. 安装mysql
  1. 安装mysql所需的依赖包

[root@mysql_5 software]# rpm -qa|grep ncurses

ncurses-base-5.7-4.20090207.el6.x86_64

ncurses-libs-5.7-4.20090207.el6.x86_64

ncurses-5.7-4.20090207.el6.x86_64

[root@mysql_5 software]# yum list|grep ncurses-devel

ncurses-devel.i686                      5.7-4.20090207.el6          rhel-source

ncurses-devel.x86_64                    5.7-4.20090207.el6          rhel-source

[root@mysql_5 software]# yum install ncurses-devel -y

 

 

  1. 创建mysql的用户和组

[root@mysql_5 mysql-5.5.32]# useradd mysql -s /sbin/nologin -M

[root@mysql_5 mysql-5.5.32]# id mysql

uid=500(mysql) gid=500(mysql) groups=500(mysql)

  1. 编译安装mysql

[root@mysql_5 software]# mkdir /application

[root@mysql_5 software]# tar zxf mysql-5.5.32.tar.gz

[root@mysql_5 software]# cd mysql-5.5.32

[root@mysql_5 mysql-5.5.32]#

 

cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \

-DMYSQL_DATADIR=/application/mysql-5.5.32/data \

-DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \

-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

 

[root@mysql_5 mysql-5.5.32]#make && make install

 

  1. 软连接mysql安装目录

[root@mysql_5 software]# cd /application/

[root@mysql_5 application]# ls

mysql-5.5.32

[root@mysql_5 application]# ln -s mysql-5.5.32/ mysql

[root@mysql_5 application]# ll

total 4

lrwxrwxrwx.  1 root root   13 Sep 18 06:52 mysql -> mysql-5.5.32/

drwxr-xr-x. 13 root root 4096 Sep 18 06:51 mysql-5.5.32

  1. 初始化配置mysql
  1. 创建mysql安装目录的软连接

[root@mysql_5 application]# cp /software/mysql-5.5.32/support-files/my-small.cnf /etc/my.cnf

 

  1. mysql数据目录授权

[root@mysql_5 application]# chown -R mysql.mysql /application/mysql/data

[root@mysql_5 application]# ls -ld /application/mysql/data/

drwxr-xr-x. 3 mysql mysql 4096 Sep 18 06:50 /application/mysql/data/

  1. 初始化mysql

[root@mysql_5 application]# cd /application/mysql/scripts/

[root@mysql_5 scripts]# ls

mysql_install_db

[root@mysql_5 scripts]# ./mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data/ --user=mysq

 

  1. 启动mysql

[root@mysql_5 scripts]# cp /software/mysql-5.5.32/support-files/mysql.server /etc/init.d/mysqld

[root@mysql_5 scripts]# chmod +x /etc/init.d/mysqld

[root@mysql_5 scripts]# /etc/init.d/mysqld start

Starting MySQL...                                          [  OK  ]

 

  1. 添加mysql的环境变量

[root@mysql_5 ~]# echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile

[root@mysql_5 ~]# tail -1 /etc/profile

export PATH=/application/mysql/bin:$PATH

[root@mysql_5 ~]# source /etc/profile

[root@mysql_5 ~]# which mysql

/application/mysql/bin/mysql

 

  1. 进入mysql数据库

[root@mysql_5 ~]# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.5.32 Source distribution

 

Copyright (c) 2000, 2013, 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> select user,host from mysql.user;

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

| user | host          |

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

| root | 127.0.0.1     |

| root | ::1           |

|      | localhost     |

| root | localhost     |

|      | mysql\_5.5.32 |

| root | mysql\_5.5.32 |

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

6 rows in set (0.00 sec)

 

mysql> drop user ''@'localhost';

Query OK, 0 rows affected (0.00 sec)

 

mysql> drop user ''@'mysql\_5.5.32';

Query OK, 0 rows affected (0.00 sec)

 

mysql> drop user 'root'@'::1';

Query OK, 0 rows affected (0.00 sec)

 

mysql> drop user 'root'@'mysql\_5.5.32';

Query OK, 0 rows affected (0.00 sec)

 

mysql> select user,host from mysql.user;

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

| user | host      |

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

| root | 127.0.0.1 |

| root | localhost |

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

2 rows in set (0.00 sec)

 

[root@mysql_5 ~]# /application/mysql/bin/mysqladmin -u root password 'system123...'
[root@mysql_5 ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@mysql_5 ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.5.32 Source distribution

Copyright (c) 2000, 2013, 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> 
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值