Linux中使用最广泛的数据库就是MySQL,使用在线yum的方式安装的版本落后MySQL网站好几个小版本,本节亲自测试安装新版的MySQL。
VMware Workstation 10 虚拟机
内存:1G
Linux版本:CentOS MinimalCD 6.5
JAVA:JAVA_HOME=/opt/jdk
安装mysql前需要查询系统中含有的有关mysql的软件。
rpm -qa | grep -i mysql //grep -i是不分大小写字符查询,只要含有mysql就显示
mysql-libs-5.1.71-1.el6.i686 //它是好几个软件的依赖,其中在mini版本中postfix软件依赖mysql-libs,网络上很多建议都是直接删除,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。
下载mysql地址:http://dev.mysql.com/downloads/mysql/
CentOS是RedHatLinux系列的,因此选择RedHatLinux(见红线地方),网页会自动变成RedHatLinux有关的mysql下载:
需要下载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。
#tar xvf MySQL-5.6.21-1.el6.i686.rpm-bundle.tar MySQL-client-5.6.21-1.el6.i686.rpmMySQL-devel-5.6.21-1.el6.i686.rpmMySQL-shared-5.6.21-1.el6.i686.rpmMySQL-test-5.6.21-1.el6.i686.rpmMySQL-server-5.6.21-1.el6.i686.rpmMySQL-embedded-5.6.21-1.el6.i686.rpm#ls -ltotal 415068-rw-r--r--. 1 root root 210442240 Nov 11 11:12 MySQL-5.6.21-1.el6.i686.rpm-bundle.tar-rw-r--r--. 1 7155 wheel 17813608 Sep 12 16:25 MySQL-client-5.6.21-1.el6.i686.rpm-rw-r--r--. 1 7155 wheel 3131328 Sep 12 16:25 MySQL-devel-5.6.21-1.el6.i686.rpm-rw-r--r--. 1 7155 wheel 83106000 Sep 12 16:25 MySQL-embedded-5.6.21-1.el6.i686.rpm-rw-r--r--. 1 7155 wheel 54611632 Sep 12 16:26 MySQL-server-5.6.21-1.el6.i686.rpm-rw-r--r--. 1 7155 wheel 1878756 Sep 12 16:27 MySQL-shared-5.6.21-1.el6.i686.rpm-rw-r--r--. 1 root root 4141488 Nov 18 14:42 MySQL-shared-compat-5.6.21-1.el6.i686.rpm-rw-r--r--. 1 7155 wheel 49887932 Sep 12 16:27 MySQL-test-5.6.21-1.el6.i686.rpm
# rpm -i MySQL-shared-compat-5.6.21-1.el6.i686.rpm# rpm -qa | grep -i mysqlmysql-libs-5.1.71-1.el6.i686MySQL-shared-compat-5.6.21-1.el6.i686# yum remove mysql-libs
# rpm -ivh --test MySQL-server-5.6.21-1.el6.i686.rpm# yum install perl
# rpm -ivh MySQL-server-5.6.21-1.el6.i686.rpmPreparing... ########################################### [100%] 1:MySQL-server ########################################### [100%]………………………………A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !You will find that password in '/root/.mysql_secret'.You must change that password on your first connect,no other statement but 'SET PASSWORD' will be accepted.See the manual for the semantics of the 'password expired' flag.Also, the account for the anonymous user has been removed.In addition, you can run: /usr/bin/mysql_secure_installation………………………………# rpm -ivh MySQL-client-5.6.21-1.el6.i686.rpmPreparing... ########################################### [100%] 1:MySQL-client ########################################### [100%]
#more .mysql_secret# The random password set for the root user at Tue Nov 18 22:57:46 2014 (local time): NljqL63OYlGo5cqy <– 得到root访问mysql的密码:NljqL63OYlGo5cqy# service mysql startStarting MySQL... SUCCESS! # /usr/bin/mysql_secure_installation --user=mysqlNOTE: 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 currentpassword for the root user. If you've just installed MySQL, andyou 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的密码 NljqL63OYlGo5cqyOK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MySQLroot 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并回车,强烈建议更换New password: <– 设置root用户的密码Re-enter new password: <– 再输入一次你设置的密码Password updated successfully!Reloading privilege tables.. ... Success!By default, a MySQL installation has an anonymous user, allowing anyoneto log into MySQL without having to have a user account created forthem. This is intended only for testing, and to make the installationgo a bit smoother. You should remove them before moving into aproduction environment.Remove anonymous users? [Y/n] y <– 是否删除匿名用户,生产环境建议删除,所以输入y并回车 ... Success!Normally, root should only be allowed to connect from 'localhost'. Thisensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] y <–是否禁止root远程登录,根据自己的需求选择Y/n并回车,建议禁止 ... Success!By default, MySQL comes with a database named 'test' that anyone canaccess. This is also intended only for testing, and should be removedbefore moving into a production environment.Remove test database and access to it? [Y/n] y <– 是否删除test数据库,输入y并回车 - Dropping test database... ... Success! - Removing privileges on test database... ... Success!Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.Reload privilege tables now? [Y/n] y 是否重新加载权限表,输入y并回车 ... Success!All done! If you've completed all of the above steps, your MySQLinstallation should now be secure.Thanks for using MySQL!Cleaning up...
# chkconfigauditd 0:off 1:off 2:on 3:on 4:on 5:on 6:offblk-availability 0:off 1:on 2:on 3:on 4:on 5:on 6:offcrond 0:off 1:off 2:on 3:on 4:on 5:on 6:offip6tables 0:off 1:off 2:on 3:on 4:on 5:on 6:offiptables 0:off 1:off 2:on 3:on 4:on 5:on 6:offiscsi 0:off 1:off 2:off 3:on 4:on 5:on 6:offiscsid 0:off 1:off 2:off 3:on 4:on 5:on 6:offlvm2-monitor 0:off 1:on 2:on 3:on 4:on 5:on 6:offmdmonitor 0:off 1:off 2:on 3:on 4:on 5:on 6:offmultipathd 0:off 1:off 2:off 3:off 4:off 5:off 6:offmysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off <-看到这个OK了netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:offnetfs 0:off 1:off 2:off 3:on 4:on 5:on 6:offnetwork 0:off 1:off 2:on 3:on 4:on 5:on 6:offpostfix 0:off 1:off 2:on 3:on 4:on 5:on 6:offrdisc 0:off 1:off 2:off 3:off 4:off 5:off 6:offrestorecond 0:off 1:off 2:off 3:off 4:off 5:off 6:offrsyslog 0:off 1:off 2:on 3:on 4:on 5:on 6:offsaslauthd 0:off 1:off 2:off 3:off 4:off 5:off 6:offsshd 0:off 1:off 2:on 3:on 4:on 5:on 6:offudev-post 0:off 1:on 2:on 3:on 4:on 5:on 6:off
目录 | 目录中的内容 |
/usr/bin | 客户端程序和脚本 |
/usr/sbin | Mysqld服务器 |
/var/lib/mysql | 数据库的日志文件 |
/usr/share/info | 信息格式手册 |
/usr/share/man | Unix 手册页 |
/usr/include/mysql | 包括 (标题) 的文件 |
/usr/lib/mysql | mysql的lib包 |
/usr/share/mysql | 杂项的支持文件,包括错误消息) 字符设置的文件,示例配置文件,SQL 数据库安装 |
/usr/share/sql-bench | 基准 |