linux安装mysql-二进制安装

linux系统centos 6.5,mysql版本5.5.60

所需安装包mysql-5.5.60-linux-glibc2.12-x86_64.tar.gz、ncurses-devel-5.7-4.20090207.el6.x86_64.rpm、libaio-devel-0.3.107-10.el6.x86_64.rpm

 

创建更新包目录,并将三个安装包上传至该目录下,赋予执行权限

[root@oldboy ~]# mkdir -p /home/oldboy/tools
[root@oldboy ~]# cd /home/oldboy/tools
[root@oldboy tools]# chmod +x *
[root@oldboy tools]# rpm -ivh --nodeps ncurses-devel-5.7-4.20090207.el6.x86_64.rpm
[root@oldboy tools]# rpm -ivh libaio-devel-0.3.107-10.el6.x86_64.rpm

 

创建用户和组、解压二进制mysql安装包、并创建软连接

[root@oldboy tools]# groupadd mysql
[root@oldboy tools]# useradd -M mysql -g mysql -s /sbin/nologin
[root@oldboy tools]# tar zxf mysql-5.5.60-linux-glibc2.12-x86_64.tar.gz 
[root@oldboy tools]# mkdir -p /application/
[root@oldboy tools]# mv mysql-5.5.60-linux-glibc2.12-x86_64 /application/mysql-5.5.60
[root@oldboy tools]# ln -s /application/mysql-5.5.60/ /application/mysql

 

二进制安装mysql

[root@oldboy tools]# cd /application/mysql/scripts/
[root@oldboy scripts]# ./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
…………………
Installing MySQL system tables...
180724 15:59:23 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
180724 15:59:23 [Note] /application/mysql//bin/mysqld (mysqld 5.5.60) starting as process 48877 ...
OK
Filling help tables...
180724 15:59:23 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
180724 15:59:23 [Note] /application/mysql//bin/mysqld (mysqld 5.5.60) starting as process 48884 ...
OK
…………………
Please report any problems at http://bugs.mysql.com/

 

将mysql的可执行文件bin目录加入PATH环境变量

[root@oldboy scripts]# echo 'export PATH=/application/mysql/bin:$PATH'>>/etc/profile
[root@oldboy scripts]# source /etc/profile
[root@oldboy scripts]# echo $PATH
/application/mysql/bin:/application/mysql/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

 

复制mysql配置文件和启动文件,

[root@oldboy scripts]# cd ..
[root@oldboy mysql]# mv /etc/my.cnf /etc/my.cnf.bak
[root@oldboy mysql]# cp support-files/my-small.cnf /etc/my.cnf
[root@oldboy mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@oldboy mysql]# sed -i 's#/usr/local/mysql#/application/mysql#g' /etc/init.d/mysqld
[root@oldboy mysql]# chmod +x /etc/init.d/mysqld

 

启动mysql

[root@oldboy mysql]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/application/mysql/data/oldboy.err'.
..[  OK  ]

 

给root用户设置密码,并通过root登录mysql数据库

[root@oldboy ~]# /application/mysql//bin/mysqladmin -u root password 'oldboy'
[root@oldboy ~]# mysql -uroot -poldboy
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.60 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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 databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)

 

posted @ 2018-11-26 21:39  Forever77  阅读(300)  评论(0编辑  收藏  举报