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

[经验分享] mysql数据的安装

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-5-16 09:47:02 | 显示全部楼层 |阅读模式
说明:mysql的版本:mysql-5.5.21-linux2.6-x86_64.tar.gz
1.添加傀儡用户
[iyunv@web01 ~]# useradd  -s  /sbin/nologin  -M  mysql
[iyunv@web01 ~]# id  mysql
uid=502(mysql) gid=502(mysql) 组=502(mysql)
[iyunv@web01 ~]#
2.上传二进制包(目录没有自己创建,这是安装nginx的时候创建的目录,都放在一起)
[iyunv@web01 ~]# cd /home/oldboy/tools/
[iyunv@web01 tools]# ls
nginx-1.6.3  nginx-1.6.3.tar.gz
[iyunv@web01 tools]# rz
rz waiting to receive.
zmodem trl+C
  100%  181708 KB 8652 KB/s 00:00:21       0 Errorss86_64.tar.gz...
[iyunv@web01 tools]# ls
mysql-5.5.21-linux2.6-x86_64.tar.gz  nginx-1.6.3  nginx-1.6.3.tar.gz
[iyunv@web01 tools]#
[iyunv@web01 tools]# ls
mysql-5.5.21-linux2.6-x86_64.tar.gz  nginx-1.6.3  nginx-1.6.3.tar.gz
[iyunv@web01 tools]#
3.解压二进制包
[iyunv@web01 tools]# tar xf mysql-5.5.21-linux2.6-x86_64.tar.gz
[iyunv@web01 tools]# ls
mysql-5.5.21-linux2.6-x86_64         nginx-1.6.3
mysql-5.5.21-linux2.6-x86_64.tar.gz  nginx-1.6.3.tar.gz
[iyunv@web01 tools]#
4.二进制包不用编译,把解压的二进制包放在规定的位置,做做软连接,方便管理
[iyunv@web01 tools]# mv mysql-5.5.21-linux2.6-x86_64  /application/mysql-5.5.32
[iyunv@web01 tools]# ln -s /application/mysql-5.5.32 /application/mysql
[iyunv@web01 tools]# ll /application/mysql
lrwxrwxrwx 1 root root 25 5月  11 16:32 /application/mysql -> /application/mysql-5.5.32
[iyunv@web01 tools]#
5.初始化数据库(两个OK正确的标志)
--basedir=/application/mysql/   指定安装的目录

datadir=/application/mysql/data/  指定数据存放的位置

--user=mysql  指定用户

[iyunv@web01 ~]# /application/mysql/scripts/mysql_install_db  --basedir=/application/mysql/  --datadir=/application/mysql/data/ --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
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 with the /application/mysql//scripts/mysqlbug script!
[iyunv@web01 ~]#
6.授权mysql管理数据库文件
[iyunv@web01 ~]# chown -R mysql.mysql /application/mysql/
[iyunv@web01 ~]#
7.生成mysql的配置文件
[iyunv@web01 support-files]# pwd
/application/mysql/support-files
[iyunv@web01 support-files]# cp  my-small.cnf  /etc/my.cnf
cp:是否覆盖"/etc/my.cnf"? y
[iyunv@web01 support-files]#
8修改mysql启动的文件路径(默认是:/application/mysql/bin/mysqld_safe )
[iyunv@web01 ~]# cat /application/mysql/bin/mysqld_safe
[iyunv@web01 local]# sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe
[iyunv@web01 local]#
9.后台启动mysql
[iyunv@web01 local]# /application/mysql/bin/mysqld_safe &
[iyunv@web01 local]# lsof -i:3306
COMMAND  PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
mysqld  1712 mysql   10u  IPv4  10536      0t0  TCP *:mysql (LISTEN)
[iyunv@web01 local]#
10.mysql的命令都在/application/mysql/bin/  为了不带路径执行mysql的命令,调整PATH路径
①把mysql的命令的路径加到PATH路径下(建议使用这一种)
[iyunv@web01 ~]# PATH="/application/mysql/bin:$PATH"
spacer.jpg

②把mysql的命令拷贝到已知的PATH路径下(上课老师用的这一种,正确)
[iyunv@web01 bin]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[iyunv@web01 bin]# cp  /application/mysql/bin/*  /usr/local/sbin/
[iyunv@web01 bin]# which  mysql
/usr/local/sbin/mysql
[iyunv@web01 bin]#
11.调整启动的方式
[iyunv@web01 ~]#cp  /application/mysql/support-files/mysql.server   /etc/init.d/mysqld
[iyunv@web01 ~]#  sed -i 's#/usr/local/mysql#/application/mysql#g' /etc/init.d/mysqld  
[iyunv@web01 ~]# chmod +x /etc/init.d/mysqld
[iyunv@web01 ~]#
12.测试启动顺序的调整(生产环境不要用pkill)
[iyunv@web01 ~]# killall  mysqld
[iyunv@web01 ~]# lsof -i:3306
[iyunv@web01 ~]#
[iyunv@web01 ~]# /etc/init.d/mysqld  start
Starting MySQL.. SUCCESS!
[iyunv@web01 ~]#
13.加入开机自启服务
[iyunv@web01 ~]# chkconfig mysqld on
[iyunv@web01 ~]# chkconfig --list  mysqld
mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off
[iyunv@web01 ~]#
14.修改mysql的密码(默认是没有密码的)
[iyunv@web01 ~]# mysqladmin -uroot password "123456"
测试:
[iyunv@web01 ~]# mysql -uroot  -p123456
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.5.21 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, 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>
15.mysql更改已知的密码
[iyunv@web01 ~]# mysqladmin  -uroot -p123456 password "oldboy"
[iyunv@web01 ~]# mysql -uroot -p123456
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[iyunv@web01 ~]# mysql -uroot -poldboy
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.5.21 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, 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>

16.交互式给密码(这样在history历史记录没有办法看到密码)
[iyunv@web01 ~]# mysqladmin  -uroot -p123456 password "oldboy"
[iyunv@web01 ~]# mysql -uroot -p123456
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[iyunv@web01 ~]# mysql -uroot -poldboy
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.5.21 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, 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>



运维网声明 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-217593-1-1.html 上篇帖子: DRBD+Heartbeat+Mysql 高可用实战 下篇帖子: MySQL高可用之MHA—其它高可用解决方案和问题 mysql
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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