CentOS安装MySQL数据库的三种方法.docx_第1页
CentOS安装MySQL数据库的三种方法.docx_第2页
CentOS安装MySQL数据库的三种方法.docx_第3页
CentOS安装MySQL数据库的三种方法.docx_第4页
CentOS安装MySQL数据库的三种方法.docx_第5页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

最近在CentOS 5.10上安装最新版的mysql5.6.21时遇到了麻烦。于是将mysql文档中的关于如何在Linux上安装mysql的部分仔细的读了一遍。总结起来在CentOS或者Red Hat上安装mysql可以有三种方式:1)使用rpm -ivh .或者 yum install . (一般推荐使用rpm来安装)2)使用编译好的通用二进制版本的mysql来安装(Generic Binaries mysql) (在方法一失败时,可以使用方法2来安装)3)使用源码来编译安装。1. 在CentOS 5.10上安装最新版的mysql5.6.21时遇到的麻烦2. Installing MySQL on Unix/Linux Using Generic Binaries(使用通用二进制版本的mysql来安装) 当使用rpm或者yum方法安装失败时,可以使用该方法进行安装。因为通用二进制版本对glibc等lib库的版本要求不是很高。所以使用这种方法,可以很好的解决:在低版本的CentOS上安装高版本的mysql。其安装方法如下。2.1 下载 打开网页:/downloads/mysql/ 在Select Platform: 中选择 Linux - Generic 然后下载最下面的:mysql-5.6.21-linux-glibc2.5-i686.tar.gz (有64位的和32位的,选择自己需要的)2.2 安装 具体安装步骤,mysql文档中有详细说明:To install and user a MySQL binary distribution, the basic command sequence looks like this:shell groupadd mysqlshell useradd -r -g mysql mysqlshell cd /usr/localshell tar zxvf /path/to/mysql-VERSION-OS.tar.gzshell ln -s full-path-to-mysql-VERSION-OSmysqlshell cd mysqlshell chown -R mysql .shell chgrp -R mysql .shell scripts/mysql_install_db -user=mysqlshell chown -R root .shell chown -R mysql datashell bin/mysqld_safe -user=mysql &# Next command is optionalshell cp support-files/mysql.server /etc/init.d/mysql.server我自己的安装过程如下:rootlocalhost mysql# groupadd mysqlrootlocalhost mysql# useradd -r -g mysql mysqlrootlocalhost mysql# cd /usr/localrootlocalhost mysql# tar zxvf /root/mysql-5.6.21-linux-glibc2.5-i686.tar.gz rootlocalhost local# lltotal 76drwxr-xr-x 2 root root 4096 Nov 7 05:43 bindrwxr-xr-x 2 root root 4096 May 11 2011 etcdrwxr-xr-x 2 root root 4096 May 11 2011 gamesdrwxr-xr-x 3 root root 4096 Nov 7 05:43 includedrwxr-xr-x 4 root root 4096 Nov 7 05:43 libdrwxr-xr-x 2 root root 4096 May 11 2011 libexecdrwxr-xr-x 13 root root 4096 Nov 7 20:42 mysql-5.6.21-linux-glibc2.5-i686drwxr-xr-x 2 root root 4096 May 11 2011 sbindrwxr-xr-x 4 root root 4096 Nov 7 01:15 sharedrwxr-xr-x 2 root root 4096 May 11 2011 srcrootlocalhost local# pwd/usr/localrootlocalhost local# ln -s /usr/local/mysql-5.6.21-linux-glibc2.5-i686 mysqlrootlocalhost local# cd mysqlrootlocalhost mysql# chown -R mysql .rootlocalhost mysql# chgrp -R mysql .rootlocalhost mysql# scripts/mysql_install_db -user=mysqlInstalling MySQL system tables.2014-11-07 20:45:37 0 Warning TIMESTAMP with implicit DEFAULT value is deprecated. Please use -explic it_defaults_for_timestamp server option (see documentation for more details).2014-11-07 20:45:37 4083 Note InnoDB: Using mutexes to ref count buffer pool pages2014-11-07 20:45:37 4083 Note InnoDB: The InnoDB memory heap is disabled2014-11-07 20:45:37 4083 Note InnoDB: Mutexes and rw_locks use InnoDBs own implementation2014-11-07 20:45:37 4083 Note InnoDB: Memory barrier is not used2014-11-07 20:45:37 4083 Note InnoDB: Compressed tables use zlib 1.2.32014-11-07 20:45:37 4083 Note InnoDB: Using Linux native AIO2014-11-07 20:45:37 4083 Note InnoDB: Not using CPU crc32 instructions2014-11-07 20:45:37 4083 Note InnoDB: Initializing buffer pool, size = 128.0M2014-11-07 20:45:37 4083 Note InnoDB: Completed initialization of buffer pool2014-11-07 20:45:37 4083 Note InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!2014-11-07 20:45:37 4083 Note InnoDB: Setting file ./ibdata1 size to 12 MB2014-11-07 20:45:37 4083 Note InnoDB: Database physically writes the file full: wait.2014-11-07 20:45:37 4083 Note InnoDB: Setting log file ./ib_logfile101 size to 48 MB2014-11-07 20:45:38 4083 Note InnoDB: Setting log file ./ib_logfile1 size to 48 MB2014-11-07 20:45:38 4083 Note InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile02014-11-07 20:45:38 4083 Warning InnoDB: New log files created, LSN=457812014-11-07 20:45:38 4083 Note InnoDB: Doublewrite buffer not found: creating new2014-11-07 20:45:38 4083 Note InnoDB: Doublewrite buffer created2014-11-07 20:45:38 4083 Note InnoDB: 128 rollback segment(s) are active.2014-11-07 20:45:38 4083 Warning InnoDB: Creating foreign key constraint system tables.2014-11-07 20:45:39 4083 Note InnoDB: Foreign key constraint system tables created2014-11-07 20:45:39 4083 Note InnoDB: Creating tablespace and datafile system tables.2014-11-07 20:45:39 4083 Note InnoDB: Tablespace and datafile system tables created.2014-11-07 20:45:39 4083 Note InnoDB: Waiting for purge to start2014-11-07 20:45:39 4083 Note InnoDB: 5.6.21 started; log sequence number 02014-11-07 20:45:39 4083 Note Binlog end2014-11-07 20:45:39 4083 Note InnoDB: FTS optimize thread exiting.2014-11-07 20:45:39 4083 Note InnoDB: Starting shutdown.2014-11-07 20:45:41 4083 Note InnoDB: Shutdown completed; log sequence number 1625977OKFilling help tables.2014-11-07 20:45:41 0 Warning TIMESTAMP with implicit DEFAULT value is deprecated. Please use -explicit_defaults _for_timestamp server option (see documentation for more details).2014-11-07 20:45:41 4105 Note InnoDB: Using mutexes to ref count buffer pool pages2014-11-07 20:45:41 4105 Note InnoDB: The InnoDB memory heap is disabled2014-11-07 20:45:41 4105 Note InnoDB: Mutexes and rw_locks use InnoDBs own implementation2014-11-07 20:45:41 4105 Note InnoDB: Memory barrier is not used2014-11-07 20:45:41 4105 Note InnoDB: Compressed tables use zlib 1.2.32014-11-07 20:45:41 4105 Note InnoDB: Using Linux native AIO2014-11-07 20:45:41 4105 Note InnoDB: Not using CPU crc32 instructions2014-11-07 20:45:41 4105 Note InnoDB: Initializing buffer pool, size = 128.0M2014-11-07 20:45:41 4105 Note InnoDB: Completed initialization of buffer pool2014-11-07 20:45:41 4105 Note InnoDB: Highest supported file format is Barracuda.2014-11-07 20:45:41 4105 Note InnoDB: 128 rollback segment(s) are active.2014-11-07 20:45:41 4105 Note InnoDB: Waiting for purge to start2014-11-07 20:45:41 4105 Note InnoDB: 5.6.21 started; log sequence number 16259772014-11-07 20:45:41 4105 Note Binlog end2014-11-07 20:45:41 4105 Note InnoDB: FTS optimize thread exiting.2014-11-07 20:45:41 4105 Note InnoDB: Starting shutdown.2014-11-07 20:45:43 4105 Note InnoDB: Shutdown completed; log sequence number 1625987OKTo start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your systemPLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !To do so, start the server, then issue the following commands: ./bin/mysqladmin -u root password new-password ./bin/mysqladmin -u root -h localhost.localdomain password new-passwordAlternatively you can run: ./bin/mysql_secure_installationwhich will also give you the option of removing the testdatabases and anonymous user created by default. This isstrongly recommended for production servers.See the manual for more instructions.You can start the MySQL daemon with: cd . ; ./bin/mysqld_safe &You can test the MySQL daemon with mysql-test-run.pl cd mysql-test ; perl mysql-test-run.plPlease report any problems at /The latest information about MySQL is available on the web at Support MySQL by buying support/licenses at New default config file was created as ./f andwill be used by default by the server when you start it.You may edit this file to change server settingsrootlocalhost mysql# chown -R root .rootlocalhost mysql# chown -R mysql datarootlocalhost mysql# bin/mysqld_safe -user=mysql &1 4144rootlocalhost mysql# 141107 20:52:14 mysqld_safe Logging to /usr/local/mysql/data/localhost.localdomain.err.141107 20:52:14 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/datarootlocalhost mysql# cp support-files/mysql.server /etc/init.d/mysql.serverrootlocalhost mysql# ps -elf | grep mysql4 S root 4144 3430 0 85 0 - 1149 wait 20:52 pts/0 00:00:00 /bin/sh bin/mysqld_safe -user=mysql4 S mysql 4234 4144 4 76 0 - 195029 stext 20:52 pts/0 00:00:02 /usr/local/mysql/bin/mysqld -basedir=/usr/local/mysql -datad data -plugin-dir=/usr/local/mysql/lib/plugin -user=mysql -log-error=/usr/local/mysql/data/localhost.localdomain.err -pid-file=/usr/lo host.localdomain.pid0 R root 4262 3430 0 78 0 - 1008 - 20:53 pts/0 00:00:00 grep mysqlrootlocalhost mysql# ./bin/mysqladmin -u root password xxxxxxWarning: Using a password on the command line interface can be insecure.rootlocalhost mysql# ./bin/mysql_secure_installationNOTE: 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, well need the currentpassword for the root user. If youve just installed MySQL, andyou havent 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):OK, 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 n. skipping.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. 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. 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- 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. Success!All done! If youve completed all of the above steps, your MySQLinstallation should now be secure.Thanks for using MySQL!Cleaning up.修改 /root/.bash_profile中的PATH:rootlocalhost # cat /root/.bash_profile# .bash_profile# Get the aliases and functionsif -f /.bashrc ; then . /.bashrcfi# User specific environment and startup programsPATH=$PATH:/usr/local/mysql/bin:$HOME/binexport PATHunset USERNAMErootlocalhost # pwd/rootrootlocalhost # mysql -uroot -pEnter password:Welcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 14Server version: 5.6.21 MySQL Community Server (GPL)Copyright (c)

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论