ITPub博客

首页 > 数据库 > NoSQL > mysql 5.6 for linux install(three types)

mysql 5.6 for linux install(three types)

原创 NoSQL 作者:liqilin0429 时间:2015-04-22 17:06:49 0 删除 编辑


MySQL安装文档



RPM包安装方式



安装服务器端



[root@master mysql]# rpm
-ivh MySQL-server-advanced-5.6.24-1.rhel5.x86_64.rpm



Preparing...               
########################################### [100%]



  
1:MySQL-server-advanced 
########################################### [100%]



warning: user mysql does not exist - using
root



warning: group mysql does not exist - using
root



2015-04-20 18:22:59 0 [Warning] TIMESTAMP
with implicit DEFAULT value is deprecated. Please use
--explicit_defaults_for_timestamp server option (see documentation for more
details).



2015-04-20 18:22:59 0 [Note]
/usr/sbin/mysqld (mysqld 5.6.24-enterprise-commercial-advanced) starting as
process 14012 ...



2015-04-20 18:23:08 14034 [Note] InnoDB:
Shutdown completed; log sequence number 1625987



..........



New default config file was created as
/usr/my.cnf and



will be used by default by the server when
you start it.



You may edit this file to change server
settings





[root@master mysql]#
service mysql status



MySQL is not running                                       [FAILED]



[root@master mysql]#
service mysql start



Starting MySQL......                                       [  OK  ]



[root@master mysql]#
service mysql status



MySQL running
(14203)                                     
[  OK  ]



安装MYSQL 客户端



[root@master mysql]# rpm -ivh
MySQL-client-advanced-5.6.24-1.rhel5.x86_64.rpm



Preparing...               
########################################### [100%]



  
1:MySQL-client-advanced 
########################################### [100%]





登陆(密码在vi  /root/.mysql_secret



# The random password set for the root user
at Mon Apr 20 18:23:04 2015 (local time): hSRBmL148_WYgHsD



[root@master mysql]# mysql -uroot -p



Enter password:



Welcome to the MySQL monitor.  Commands end with ; or \g.



Your MySQL connection id is 5



Server version:
5.6.24-enterprise-commercial-advanced





Copyright (c) 2000, 2015, 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;



ERROR 1820 (HY000): You must SET PASSWORD
before executing this statement



修改MySQL服务器的密码



mysql> set password for
root@'localhost'=password("qilin");



Query OK, 0 rows affected (0.00 sec)



查询RPM包安装详细列表



 [root@master
mysql]# rpm -ql MySQL-client-advanced



/usr/bin/msql2mysql



/usr/bin/mysql



/usr/bin/mysql_config_editor



/usr/bin/mysql_find_rows



/usr/bin/mysql_waitpid



/usr/bin/mysqlaccess



/usr/bin/mysqlaccess.conf



/usr/bin/mysqladmin



/usr/bin/mysqlbinlog



/usr/bin/mysqlcheck



/usr/bin/mysqldump



/usr/bin/mysqlimport



/usr/bin/mysqlshow



/usr/bin/mysqlslap



/usr/share/doc/MySQL-client-advanced-5.6.24



/usr/share/doc/MySQL-client-advanced-5.6.24/LICENSE.mysql



/usr/share/man/man1/msql2mysql.1.gz



/usr/share/man/man1/mysql.1.gz



/usr/share/man/man1/mysql_config_editor.1.gz



/usr/share/man/man1/mysql_find_rows.1.gz



/usr/share/man/man1/mysql_waitpid.1.gz



/usr/share/man/man1/mysqlaccess.1.gz



/usr/share/man/man1/mysqladmin.1.gz



/usr/share/man/man1/mysqlbinlog.1.gz



/usr/share/man/man1/mysqlcheck.1.gz



/usr/share/man/man1/mysqldump.1.gz



/usr/share/man/man1/mysqlimport.1.gz



/usr/share/man/man1/mysqlshow.1.gz



卸载安装包



[root@master mysql]# rpm -e MySQL-client-advanced



源码编译安装方式



安装系统的包(Cmake所需要)



创建目录



[root@master ~]# mkdir -p /mnt/flash



挂载光盘



[root@master ~]# mount /mnt/flash
/dev/cdrom



mount: /mnt/flash is not a block device



[root@master ~]# cd /mnt/flash



[root@master flash]# ls



blafdoc.css 
ClusterStorage  eula.en_US  GPL    
isolinux   README-en.html    RELEASE-NOTES-en.html  RPM-GPG-KEY-oracle  supportinfo 
VT



Cluster     
EULA            eula.py     images 
README-en  RELEASE-NOTES-en  RPM-GPG-KEY            Server              TRANS.TBL



如果无法挂载成功,需要重新启动服务器,再次加载光盘就可以



安装相应的包



[root@master Server]# rpm -ivh gcc* --force
--nodeps



warning: gcc-4.1.2-46.el5.x86_64.rpm:
Header V3 DSA signature: NOKEY, key ID 1e5e0159



Preparing...               
########################################### [100%]



  
1:gcc                   
########################################### [ 10%]



  
2:gcc44                  ###########################################
[ 20%]



  
3:gcc-c++               
########################################### [ 30%]



  
4:gcc-objc              
########################################### [ 40%]



  
5:gcc44-c++             
########################################### [ 50%]



  
6:gcc44-gfortran        
########################################### [ 60%]



  
7:gcc-gfortran          
########################################### [ 70%]



  
8:gcc-gnat              
########################################### [ 80%]



  
9:gcc-java              
########################################### [ 90%]



 
10:gcc-objc++            
########################################### [100%]



[root@master Server]#



Cmake安装部署



下载Cmake包(源码包)



http://www.cmake.org/download/



编译



root@master cmake-2.8.12.2]# ./bootstrap



........



-- Generating done



-- Build files have been written to:
/root/soft/source/cmake/cmake-2.8.12.2



---------------------------------------------



CMake has bootstrapped.  Now run gmake.



[root@master cmake-2.8.12.2]# make



........



[ 99%] Built target pseudo_BC



[ 99%] Building CXX object
Tests/CTestTestMemcheck/CMakeFiles/pseudo_purify.dir/ret0.cxx.o



Linking CXX executable purify



[ 99%] Built target pseudo_purify



[100%] Building CXX object Tests/CTestTestMemcheck/CMakeFiles/pseudo_valgrind.dir/ret0.cxx.o



Linking CXX executable valgrind



[100%] Built target pseudo_valgrind



Scanning dependencies of target pseudonl_BC



[100%] Building C object
Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeFiles/pseudonl_BC.dir/ret0.c.o



Linking C executable BC



[100%] Built target pseudonl_BC



Scanning dependencies of target
pseudonl_purify



[100%] Building C object
Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeFiles/pseudonl_purify.dir/ret0.c.o



Linking C executable purify



[100%] Built target pseudonl_purify



Scanning dependencies of target
pseudonl_valgrind



[100%] Building C object
Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeFiles/pseudonl_valgrind.dir/ret0.c.o



Linking C executable valgrind



[100%] Built target pseudonl_valgrind





[root@master cmake-2.8.12.2]# make install



........



-- Installing:
/usr/local/doc/cmake-2.8/cpack.docbook



-- Installing:
/usr/local/doc/cmake-2.8/ccmake.docbook



-- Up-to-date:
/usr/local/share/aclocal/cmake.m4



-- Up-to-date: /usr/local/share/cmake-2.8/editors/vim/cmake-help.vim



-- Up-to-date:
/usr/local/share/cmake-2.8/editors/vim/cmake-indent.vim



-- Up-to-date:
/usr/local/share/cmake-2.8/editors/vim/cmake-syntax.vim



-- Up-to-date:
/usr/local/share/cmake-2.8/editors/emacs/cmake-mode.el



-- Up-to-date:
/usr/local/share/cmake-2.8/completions/cmake



-- Up-to-date:
/usr/local/share/cmake-2.8/completions/cpack



-- Up-to-date:
/usr/local/share/cmake-2.8/completions/ctest



解压



[root@master cmake]# tar -zxvf
cmake-3.2.2-Linux-x86_64.tar.gz



编译



在编译时会报各种各样的错误,是由于缺少相应的包(kernel*libc*libgn*libc*glibc*gmp*bison.i686gcc-c++ncurses.i686),导致了各种错误的产生



[root@master cmake-2.8.12.2]# ./bootstrap



[root@master cmake-2.8.12.2]#



[root@master cmake-2.8.12.2]# make
&& make install



创建用户组合用户



[root@master ~]# groupadd mysql



groupadd: group mysql exists



[root@master ~]# groupdel mysqsl



groupdel: group mysqsl does not exist



[root@master ~]# groupdel mysql



groupdel: cannot remove
user's primary group.



因为这个组mysql里面还有用户。所以在删除用户组前,一定要查看这个组中还有没有成员了。



 [root@master
~]# tail -n 7 /etc/group /etc/gshadow



==> /etc/group <==



dbus:x:81:



avahi:x:70:



haldaemon:x:68:



avahi-autoipd:x:101:



gdm:x:42:



sabayon:x:86:



mysql:x:102:





==> /etc/gshadow <==



dbus:x::



avahi:x::



haldaemon:x::



avahi-autoipd:x::



gdm:x::



sabayon:x::



mysql:!::



[root@master ~]# userdel mysql



[root@master ~]# tail -n 7 /etc/group
/etc/gshadow



==> /etc/group <==



nfsnobody:x:4294967294:



dbus:x:81:



avahi:x:70:



haldaemon:x:68:



avahi-autoipd:x:101:



gdm:x:42:



sabayon:x:86:





==> /etc/gshadow <==



nfsnobody:x::



dbus:x::



avahi:x::



haldaemon:x::



avahi-autoipd:x::



gdm:x::



sabayon:x::





[root@master ~]# groupadd mysql



[root@master ~]# useradd -g mysql mysql



创建安装目录及数据库存放目录



[root@master ~]# mkdir -p /usr/local/mysql       --安装MySQL



[root@master ~]# mkdir -p
/usr/local/mysql/data   --
存放数据库



设置目录权限



[root@master ~]# cd /usr/local/mysql



[root@master mysql]# chown -R root:mysql



chown: missing operand after `root:mysql'



Try `chown --help' for more information.



[root@master mysql]# chown -R root:mysql .  
--
把当前目录中所有文件的所有者所有者设为root,所属组为mysql



[root@master mysql]# chown -R mysql:mysql
data



修改系统资源的限制



安装MySQL



解压



[root@master mysql-5.6.17]# unzip
mysql-5.6.17.zip



安装



[root@master mysql-5.6.17]#cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \  -DMYSQL_DATADIR=/usr/local/mysql/data \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \



-DEXTRA_CHARSETS=all \

-DENABLED_LOCAL_INFILE=1 \



-DMYSQL_USER=mysql  



注意一



      在初次cmake,有报错误时,需要重新重新编译时,必须清除旧的对象文件和缓存信息。



[root@master
cmake-2.8.12.2]# make clean



[root@master
cmake-2.8.12.2]# rm -f CMakeC



 [root@master cmake-2.8.12.2]# rm -f
CMakeCache.txt



注意二



     如果再安装了相应的包后,还是报同样的错误。把MySQL源码解压包删除了,从新解压一次,再次运行上面的语句就可以了





[root@master mysql-5.6.17]# make



[root@master mysql-5.6.17]# make
install





添加MySQL自动启动到系统服务中(可选)



[root@master ~]# cp
support-files/my-medium.cnf /etc/my.cnf
 //mysql的启动服务添加到系统服务中



创建系统数据库的表



[root@master mysql]# pwd



/usr/local/mysql



[root@master mysql]#
scripts/mysql_install_db --user=mysql





设置环境变量



[root@master ~]# pwd



/root



[root@master ~]# vi .bash_profile



PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib



:/usr/local/mysql/bin:/usr/local/mysql/lib需要在.bash_profile



文件的PATH中添加



[root@master ~]# source .bash_profile





手动启动



[root@master mysql]# pwd



/usr/local/mysql



[root@master mysql]# ./bin/mysqld_safe
--user=mysql &



[1] 3004



[root@master mysql]# 150421 19:27:56
mysqld_safe Logging to '/usr/local/mysql/data/master.err'.



150421 19:27:56 mysqld_safe Starting mysqld
daemon with databases from /usr/local/mysql/data





手动关闭



[root@master
mysql]#
mysqladmin -u root -p shutdown 



Enter password:



这里MySQLroot用户还没有配置密码,所以为空值。需要输入密码时,直接点回车键即可。





修改MySQLroot用户密码以及打开远程连接



[root@master ~]# mysql -uroot -p



Enter password:



Welcome to the MySQL monitor.  Commands end with ; or \g.



Your MySQL connection id is 2



Server version: 5.6.17 Source distribution





Copyright (c) 2000, 2014, 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>



mysql> show databases;



+--------------------+



| Database           |



+--------------------+



| information_schema |



| mysql              |



| performance_schema |



| test               |



+--------------------+



4 rows in set (0.00 sec)





mysql> use mysql;



Database changed



mysql> desc user;



+------------------------+-----------------------------------+------+-----+---------+-------+



| Field                  | Type                              | Null | Key | Default
| Extra |



+------------------------+-----------------------------------+------+-----+---------+-------+



.......



| authentication_string  | text                              | YES  |     |
NULL    |       |



| password_expired       | enum('N','Y')                     | NO   |    
| N       |       |



+------------------------+-----------------------------------+------+-----+---------+-------+



43 rows in set (0.00 sec)



打开远程连接



mysql> grant all privileges on * * to root@"%"
identified by "root";



ERROR 1064 (42000): You have an error in
your SQL syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use near '* to root@"%" identified by
"root"' at line 1



mysql> GRANT ALL PRIVILEGES ON *.* TO
root@"%" IDENTIFIED BY "root";



Query OK, 0 rows affected (0.00 sec)



修改密码



mysql> update user set
Password=password('qilin') where User='root';



Query OK, 5 rows affected (0.03 sec)



Rows matched: 5  Changed: 5 
Warnings: 0





mysql> select Host,User,Password from
user where User='root';



+-----------+------+-------------------------------------------+



| Host     
| User | Password                                  |



+-----------+------+-------------------------------------------+



| localhost | root |
*A510E0B2BBC95E9DAD498681F2DDD77A9B642EB6 |



| master   
| root | *A510E0B2BBC95E9DAD498681F2DDD77A9B642EB6 |



| 127.0.0.1 | root |
*A510E0B2BBC95E9DAD498681F2DDD77A9B642EB6 |



| ::1      
| root | *A510E0B2BBC95E9DAD498681F2DDD77A9B642EB6 |



| %        
| root | *A510E0B2BBC95E9DAD498681F2DDD77A9B642EB6 |



+-----------+------+-------------------------------------------+



5 rows in set (0.00 sec)





mysql> flush privileges;



Query OK, 0 rows affected (0.00 sec)





mysql> exit



Bye



重新登录验证设置的密码



[root@master ~]# mysql -uroot -p



Enter password:



Welcome to the MySQL monitor.  Commands end with ; or \g.



Your MySQL connection id is 3



Server version: 5.6.17 Source distribution





Copyright (c) 2000, 2014, 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>



二进制包安装方式



下载二进制包



下载二进制包文件名类似为:mysql-VERSION-OS-PLATFORM.tar.gz



选择二进制版本的优点是:第一
它是针对特定平台专门优化过的,安装时不需要考虑环境是否符合要求(不用单独安装CMAKE,LINUX6.0后,CMAKE自动安装在操作系统中);第二
安装简单,直接解压就可以了。



创建用户组和用户



创建相应的目录



授予相应的权限



解压



[root@slave soft]# tar -zxvf
mysql-5.5.41-linux2.6-x86_64.tar.gz  -C
/usr/local/mysql



解压到了指定的目录下,



在源码包的基础上创建二进制包,就可以利用源码包的定制性能和二进制包的可移植特性,通过使以下下打包命令



[root@master mysql-5.6.17]# tar -cvfz
/root/mysql-5.6.tar.gz /root/soft/source/source_package/mysql-5.6.17/



这样就会创建一份二进制包()了,这个包就是我们使用二进制包来进行安装的安装包了,如果有其他服务器安装MYSQL,我们只要将这个包复制到相应的目录下,进行指定目录的解压就可以了。比如创建用户,创建目录,授予权限再次执行就可以了



其他操作



剩下的步骤与源码安装编译后的步骤一致



把源码编译安装完成的,



来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/20976446/viewspace-1591597/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-08-13

  • 博文量
    100
  • 访问量
    197776