设为首页 收藏本站
查看: 535|回复: 0

[经验分享] mysql数据库安装实战(二进制安装)

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2017-8-24 08:38:37 | 显示全部楼层 |阅读模式
1    安装环境准备:
环境:CentOS 6.8 64位
安装二进制分发版 mysql-5.5.49-linux2.6-x86_64.tar.gz
myseql 二进制包下载地址:
https://downloads.mysql.com/archives/community/
http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.49-linux2.6-x86_64.tar.gz
wKiom1mddefw2gTKAAO2cAlZY60319.jpg
wKiom1mddfKCBOiDAAQzHGUTBBY147.jpg
    上传mysql-5.5.49-linux2.6-x86_64.tar.gz 二进制包到/home/oldboy/tools目录下面
1
2
3
4
5
6
7
[iyunv@web01 ~]# cd /home/oldboy/tools
[iyunv@web01 tools]# rz -y       #上传mysql-5.5.49-linux2.6-x86_64.tar.gz到当前目录下
[iyunv@web01 tools]# ls -hil
total 179M
261195 -rw-r--r-- 1 root root 178M Aug 23 19:57 mysql-5.5.49-linux2.6-x86_64.tar.gz
261198 drwxr-xr-x 9 1001 1001 4.0K Aug 19 16:11 nginx-1.6.3
261196 -rw-r--r-- 1 root root 787K Apr  8  2015 nginx-1.6.3.tar.gz



    创建用户:命令useradd mysql -s /sbin/nologin -M和useradd -s /sbin/nologin mysql -M是一样的。
1
2
3
[iyunv@web01 tools]# useradd -s /sbin/nologin mysql -M
[iyunv@web01 tools]# id mysql
uid=504(mysql) gid=504(mysql) groups=504(mysql)



    解压mysql二进制包:
1
2
3
4
[iyunv@web01 tools]#  tar xf mysql-5.5.49-linux2.6-x86_64.tar.gz
[iyunv@web01 tools]# ls
mysql-5.5.49-linux2.6-x86_64         nginx-1.6.3
mysql-5.5.49-linux2.6-x86_64.tar.gz  nginx-1.6.3.tar.gz



    移动mysql
1
[iyunv@web01 tools]# mv mysql-5.5.49-linux2.6-x86_64 /application/mysql-5.5.49



    创建软链接
1
[iyunv@web01 tools]# ln -s /application/mysql-5.5.49/ /application/mysql



    授权
1
2
3
4
5
[iyunv@web01 tools]# cd /application/mysql
[iyunv@web01 mysql]# chown -R mysql.mysql /application/mysql/
[iyunv@web01 mysql]# ls
COPYING         README  data  include  man         scripts  sql-bench
INSTALL-BINARY  bin     docs  lib      mysql-test  share    support-files



    安装mysql并指定mysql根路径和数据文件路径
1
[iyunv@web01 mysql]# ./scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/



此步骤操作看到如下两个OK就代表安装完成了。
[iyunv@web01 mysql]# ./scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/
Installing MySQL system tables...
170823 21:00:53 [Note] /application/mysql//bin/mysqld (mysqld 5.5.49) starting as process 1756 ...
OK
Filling help tables...
170823 21:00:53 [Note] /application/mysql//bin/mysqld (mysqld 5.5.49) starting as process 1763 ...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/application/mysql//bin/mysqladmin -u root password 'new-password'
/application/mysql//bin/mysqladmin -u root -h web01 password 'new-password'
Alternatively you can run:
/application/mysql//bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /application/mysql/ ; /application/mysql//bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /application/mysql//mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
    上面的安装就生成内部两个管理库:mysql和performance_schema
1
2
3
4
5
[iyunv@web01 mysql]# ll data/
total 12
drwx------ 2 mysql root  4096 Aug 23 21:00 mysql
drwx------ 2 mysql mysql 4096 Aug 23 21:00 performance_schema
drwxr-xr-x 2 mysql mysql 4096 Aug 23 20:46 test



    做个调整
1
2
[iyunv@web01 mysql]# cd bin/
[iyunv@web01 bin]# less mysqld_safe



    启动文件mysqld_safe默认的路径是/usr/local需要替换成/application/,测试下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[iyunv@web01 bin]# sed 's#/usr/local/#/application/#g' mysqld_safe |grep application
if echo '/application/mysql/share' | grep '^/application/mysql' > /dev/null
  relpkgdata=`echo '/application/mysql/share' | sed -e 's,^/application/mysql,,' -e 's,^/,,' -e 's,^,./,'`
  relpkgdata='/application/mysql/share'
  MY_BASEDIR_VERSION='/application/mysql'
  ledir='/application/mysql/bin'
  DATADIR=/application/mysql/data
elif test -x /application/mysql/bin/my_print_defaults
  print_defaults="/application/mysql/bin/my_print_defaults"
elif test -x /application/mysql/bin/mysql_print_defaults
  print_defaults="/application/mysql/bin/mysql_print_defaults"
    plugin_dir='/application/mysql/lib/plugin'
[iyunv@web01 bin]# sed 's#/usr/local/#/application/#g' mysqld_safe |grep application
if echo '/application/mysql/share' | grep '^/application/mysql' > /dev/null
  relpkgdata=`echo '/application/mysql/share' | sed -e 's,^/application/mysql,,' -e 's,^/,,' -e 's,^,./,'`
  relpkgdata='/application/mysql/share'
  MY_BASEDIR_VERSION='/application/mysql'
  ledir='/application/mysql/bin'
  DATADIR=/application/mysql/data
elif test -x /application/mysql/bin/my_print_defaults
  print_defaults="/application/mysql/bin/my_print_defaults"
elif test -x /application/mysql/bin/mysql_print_defaults
  print_defaults="/application/mysql/bin/mysql_print_defaults"
    plugin_dir='/application/mysql/lib/plugin'



    测试完成后直接替换
1
[iyunv@web01 bin]# sed -i 's#/usr/local/#/application/#g' mysqld_safe



    替换配置文件
1
2
[iyunv@web01 mysql]# cp support-files/my-small.cnf /etc/my.cnf
cp: overwrite `/etc/my.cnf'? y



    启动mysql,启动命令为/application/mysql/bin/mysqld_safe --user=mysql &
1
2
3
4
5
[iyunv@web01 mysql]# /application/mysql/bin/mysqld_safe --user=mysql &
[1] 2185
[iyunv@web01 mysql]# 170823 21:37:36 mysqld_safe Logging to '/application/mysql/data/web01.err'.
170823 21:37:36 mysqld_safe Starting mysqld daemon with databases from /application/mysql/data
^C



    查看进程是否生成
1
2
3
[iyunv@web01 mysql]# lsof -i :3306
COMMAND  PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
mysqld  2415 mysql   10u  IPv4  20041      0t0  TCP *:mysql (LISTEN)



    优化
1
2
3
[iyunv@web01 mysql]# PATH="/application/mysql/bin:$PATH"
[iyunv@web01 mysql]# which mysql
/application/mysql/bin/mysql



    配置mysql命令的全局使用路径:用vim /etc/profile 把export PATH="/application/mysql/bin:$PATH"追加到/etc/profile最后一行
1
2
[iyunv@web01 mysql]# tail -1 /etc/profile
export PATH="/application/mysql/bin:$PATH"



    使配置生效
1
[iyunv@web01 mysql]# . /etc/profile



    已生效
1
2
[iyunv@web01 mysql]# echo $PATH
/application/mysql/bin:/application/mysql/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin



    此时输入mysql就直接进来了
1
2
3
4
5
6
7
8
9
10
[iyunv@web01 mysql]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.49 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, 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>



    这就表示成功了,quit退出mysql,再做一个调整
1
mysql> quit



    调整如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[iyunv@web01 mysql]# ll support-files/
total 96
-rwxr-xr-x 1 mysql mysql  1153 Mar  1  2016 binary-configure
-rw-r--r-- 1 mysql mysql  4528 Mar  1  2016 config.huge.ini
-rw-r--r-- 1 mysql mysql  2382 Mar  1  2016 config.medium.ini
-rw-r--r-- 1 mysql mysql  1626 Mar  1  2016 config.small.ini
-rw-r--r-- 1 mysql mysql   773 Mar  1  2016 magic
-rw-r--r-- 1 mysql mysql  4691 Mar  1  2016 my-huge.cnf
-rw-r--r-- 1 mysql mysql 19759 Mar  1  2016 my-innodb-heavy-4G.cnf
-rw-r--r-- 1 mysql mysql  4665 Mar  1  2016 my-large.cnf
-rw-r--r-- 1 mysql mysql  4676 Mar  1  2016 my-medium.cnf
-rw-r--r-- 1 mysql mysql  2840 Mar  1  2016 my-small.cnf
-rwxr-xr-x 1 mysql mysql   839 Mar  1  2016 mysql-log-rotate
-rwxr-xr-x 1 mysql mysql 10880 Mar  1  2016 mysql.server
-rwxr-xr-x 1 mysql mysql  1061 Mar  1  2016 mysqld_multi.server
-rw-r--r-- 1 mysql mysql  1326 Mar  1  2016 ndb-config-2-node.ini



1
2
3
[iyunv@web01 mysql]# sed -i 's#/usr/local/#/application/#g' support-files/mysql.server
[iyunv@web01 mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[iyunv@web01 mysql]# chmod +x /etc/init.d/mysqld



    stop mysql服务
1
2
3
4
[iyunv@web01 mysql]# /etc/init.d/mysqld stop
Shutting down MySQL.170823 21:57:02 mysqld_safe mysqld from pid file /application/mysql/data/web01.pid ended
SUCCESS!
[1]+  Done                    /application/mysql/bin/mysqld_safe --user=mysql



1
[iyunv@web01 mysql]# lsof -i :3306



    start mysql服务,出来结果
1
2
3
4
5
[iyunv@web01 mysql]# /etc/init.d/mysqld start
Starting MySQL.. SUCCESS!
[iyunv@web01 mysql]# lsof -i :3306
COMMAND  PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
mysqld  2742 mysql   10u  IPv4  20558      0t0  TCP *:mysql (LISTEN)



    设置开机自启动
1
2
3
[iyunv@web01 mysql]# chkconfig --add mysqld
[iyunv@web01 mysql]# chkconfig --list mysqld
mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off



    判断mysql是否安装成功,直接输入mysql能进入mysql界面就说明成功了,如下所示成功安装myslq。
1
2
3
4
5
6
7
8
9
10
[iyunv@web01 mysql]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.49 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, 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>




总结:
wKioL1mdnB3QgxUoAAF202jwHQY740.jpg
https://s3.51cto.com/wyfs02/M00/00/D0/wKiom1mdnCjjRbEEAAAp4NFdq78751.jpg



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-403430-1-1.html 上篇帖子: 详解如何在Redhat Linux(CentOS)下重置MySQL根(Root)密码 下篇帖子: mysql二进制安装
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表