码迷,mamicode.com
首页 > 数据库 > 详细

CentOS学习笔记--MySQL安装

时间:2014-11-27 10:30:06      阅读:400      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   ar   color   os   使用   sp   

安装mysql前需要查询系统中含有的有关mysql的软件。

  1. rpm -qa | grep -i mysql //grep -i是不分大小写字符查询,只要含有mysql就显示
屏幕显示:
  1. mysql-libs-5.1.71-1.el6.i686 //它是好几个软件的依赖,其中在mini版本中postfix软件依赖mysql-libs,网络上很多建议都是直接删除,
  2. yum remove mysql-libs 或者 rpm -e --nodeps mysql-libs-5.1.71-1.el6.i686,总觉得这样做不好,查找mysql官方资料,得到安装方法是用MySQL-shared-compat将mysql-libs-5.1.71-1.el6.i686替换为同版本后在安装mysql。
 
bubuko.com,布布扣
CentOS是RedHatLinux系列的,因此选择RedHatLinux(见红线地方),网页会自动变成RedHatLinux有关的mysql下载:
bubuko.com,布布扣
 
需要下载2个内容,一个是MySQL-5.6.21-1.el6.i686.rpm-bundle.tar,这个是几个程序的合集包,另一个是MySQL-shared-compat-5.6.21-1.el6.i686.rpm,这个是软件包包括MySQL 3.23和MySQL 4.0的共享库。如果你安装了应用程序动态连接MySQL 3.23,但是你想要升级到ySQL 4.0而不想打破库的从属关系,则安装该软件包而不要安装MySQL-shared。从MySQL 4.0.13起包含该安装软件包。
将2个文件上传到CentOS中,解压MySQL-5.6.21-1.el6.i686.rpm-bundle.tar
  1. #tar xvf MySQL-5.6.21-1.el6.i686.rpm-bundle.tar
  2. MySQL-client-5.6.21-1.el6.i686.rpm MySQL-devel-5.6.21-1.el6.i686.rpm MySQL-shared-5.6.21-1.el6.i686.rpm MySQL-test-5.6.21-1.el6.i686.rpm MySQL-server-5.6.21-1.el6.i686.rpm MySQL-embedded-5.6.21-1.el6.i686.rpm
  3. #ls -l
  4. total 415068
  5. -rw-r--r--.1 root root 210442240Nov1111:12MySQL-5.6.21-1.el6.i686.rpm-bundle.tar
  6. -rw-r--r--.17155 wheel 17813608Sep1216:25MySQL-client-5.6.21-1.el6.i686.rpm
  7. -rw-r--r--.17155 wheel 3131328Sep1216:25MySQL-devel-5.6.21-1.el6.i686.rpm
  8. -rw-r--r--.17155 wheel 83106000Sep1216:25MySQL-embedded-5.6.21-1.el6.i686.rpm
  9. -rw-r--r--.17155 wheel 54611632Sep1216:26MySQL-server-5.6.21-1.el6.i686.rpm
  10. -rw-r--r--.17155 wheel 1878756Sep1216:27MySQL-shared-5.6.21-1.el6.i686.rpm
  11. -rw-r--r--.1 root root 4141488Nov1814:42MySQL-shared-compat-5.6.21-1.el6.i686.rpm
  12. -rw-r--r--.17155 wheel 49887932Sep1216:27MySQL-test-5.6.21-1.el6.i686.rpm
安装MySQL-shared-compat替换mysql-libs,如果不替换,在删除mysql-libs,会提示postfix依赖于mysql-libs:
  1. # rpm -i MySQL-shared-compat-5.6.21-1.el6.i686.rpm
  2. # rpm -qa | grep -i mysql
  3. mysql-libs-5.1.71-1.el6.i686
  4. MySQL-shared-compat-5.6.21-1.el6.i686
  5. # yum remove mysql-libs
测试MySQL-server安装,提示需要安装perl:
  1. # rpm -ivh --test MySQL-server-5.6.21-1.el6.i686.rpm
  2. # yum install perl
安装MySQL-server,MySQL-client:
  1. # rpm -ivh MySQL-server-5.6.21-1.el6.i686.rpm
  2. Preparing...########################################### [100%]
  3. 1:MySQL-server ########################################### [100%]
  4. ………………
  5. ………………
  6. A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
  7. You will find that password in‘/root/.mysql_secret‘.
  8. You must change that password on your first connect,
  9. no other statement but ‘SET PASSWORD‘ will be accepted.
  10. See the manual for the semantics of the ‘password expired‘ flag.
  11. Also, the account for the anonymous user has been removed.
  12. In addition, you can run:
  13. /usr/bin/mysql_secure_installation
  14. ………………
  15. ………………
  16. # rpm -ivh MySQL-client-5.6.21-1.el6.i686.rpm Preparing... ########################################### [100%] 1:MySQL-client ########################################### [100%]
在安装MySQL-server,见上面的一段话,大意是全新安装设置的root密码在/root/.mysql_secret中,这时一个随机密码,你需要运行/usr/bin/mysql_secure_installation,删除anonymous用户。当然不建议用root用户来运行,rpm包已经建了一个mysql用户,可以使用这个用户:
  1. #more .mysql_secret # The random password set for the root user at Tue Nov 18 22:57:46 2014 (local t ime): NljqL63OYlGo5cqy <– 得到root访问mysql的密码:NljqL63OYlGo5cqy
  2. # service mysql start Starting MySQL... SUCCESS!
  3. # /usr/bin/mysql_secure_installation --user=mysql
  4. NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MySQL to secure it, we‘ll need the current password for the root user. If you‘ve just installed MySQL, and you haven‘t set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): <–使用刚才得到的root的密码 NljqL63OYlGo5cqy
  5. OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation. You already have a root password set, so you can safely answer ‘n‘. Change the root password? [Y/n] y <– 是否更换root用户密码,输入y并回车,强烈建议更换
  6. New password: <– 设置root用户的密码
  7. Re-enter new password: <– 再输入一次你设置的密码
  8. Password updated successfully! Reloading privilege tables.. ... Success! By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y <– 是否删除匿名用户,生产环境建议删除,所以输入y并回车
  9. ...Success! Normally, root should only be allowed to connect from ‘localhost‘. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y <–是否禁止root远程登录,根据自己的需求选择Y/n并回车,建议禁止
  10. ...Success! By default, MySQL comes with a database named ‘test‘ that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y <– 是否删除test数据库,输入y并回车
  11. - Dropping test database... ... Success! - Removing privileges on test database...
  12. ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y 是否重新加载权限表,输入y并回车
  13. ... Success! All done! If you‘ve completed all of the above steps, your MySQL installation should now be secure. Thanks for using MySQL! Cleaning up...
至此,MySQL已经安装完成,最后看一下是否已将MySQL加到开机服务里:
  1. # chkconfig
  2. auditd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  3. blk-availability 0:off 1:on 2:on 3:on 4:on 5:on 6:off
  4. crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  5. ip6tables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  6. iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  7. iscsi 0:off 1:off 2:off 3:on 4:on 5:on 6:off
  8. iscsid 0:off 1:off 2:off 3:on 4:on 5:on 6:off
  9. lvm2-monitor 0:off 1:on 2:on 3:on 4:on 5:on 6:off
  10. mdmonitor 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  11. multipathd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  12. mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off <-看到这个OK
  13. netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  14. netfs 0:off 1:off 2:off 3:on 4:on 5:on 6:off
  15. network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  16. postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  17. rdisc 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  18. restorecond 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  19. rsyslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  20. saslauthd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  21. sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  22. udev-post 0:off 1:on 2:on 3:on 4:on 5:on 6:off
MySQL安装后涉及的目录如下:
目录目录中的内容
/usr/bin 客户端程序和脚本
/usr/sbin Mysqld服务器
/var/lib/mysql 数据库的日志文件
/usr/share/info 信息格式手册
/usr/share/man Unix 手册页
/usr/include/mysql 包括 (标题) 的文件
/usr/lib/mysql 图书馆
/usr/share/mysql 杂项的支持文件,包括错误消息) 字符设置的文件,示例配置文件,SQL 数据库安装
/usr/share/sql-bench 基准
 
现在好了,可以测试你的MySQL了。
 

 



 

CentOS学习笔记--MySQL安装

标签:style   blog   http   io   ar   color   os   使用   sp   

原文地址:http://www.cnblogs.com/ysztcn/p/4125643.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!