centos 6.5 安装mysql

搭建前的准备

 输入: rpm -qa | grep mysql 查看数据库是否安装了数据库如果只出现这个:mysql-libs-5.1.73-8.el6_8.x86_64,可以不用管,

 如果出现:mysql-server-5.1.73-8.el6_8.x86_64 等等,需要把它删除
   
 rpm -e mysql  // 普通删除模式
   
 rpm -e --nodeps mysql  // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除
 
 在删除完以后我们可以通过 rpm -qa | grep mysql 命令来查看mysql是否已经卸载成功!!其实就是刚才的步骤。

**开始 yum 安装mysql **

1、 通过yum来进行mysql的安装 yum list | grep mysql  ,yum上提供的mysql数据库可下载的版本,

	mysql-libs.x86_64                           5.1.71-1.el6                 @anaconda-CentOS-201311291202.x86_64/6.5
	apr-util-mysql.x86_64                       1.3.9-3.el6_0.1              os     
	asterisk-mysql.x86_64                       1.8.32.3-2.el6               epel   
	bacula-director-mysql.x86_64                5.0.0-13.el6                 os     
	bacula-storage-mysql.x86_64                 5.0.0-13.el6                 os     
	collectd-mysql.x86_64                       4.10.9-4.el6                 epel   
	dmlite-plugins-mysql.x86_64                 0.8.6-2.el6                  epel   
	dovecot-mysql.x86_64                        1:2.0.9-22.el6               os     
	dpm-copy-server-mysql.x86_64                1.9.0-1.el6                  epel   
	dpm-name-server-mysql.x86_64                1.9.0-1.el6                  epel   
	dpm-server-mysql.x86_64                     1.9.0-1.el6                  epel   
	dpm-srm-server-mysql.x86_64                 1.9.0-1.el6                  epel   
	dspam-mysql.x86_64                          3.10.2-7.el6                 epel   
	exim-mysql.x86_64                           4.89-1.el6                   epel   
	freeradius-mysql.x86_64                     2.2.6-6.el6_7                os     
	.
	.
	.

	(可以看到我的是5.1的版本),
	
2、 安装服务端:yum install -y mysql-server mysql mysql-deve   // (网上说法)mysql-deve 主要是供自己写C程序用的头文件和静态链接库,

   如果不作C开发,可以不装。任何-devel包都是这样,
   
   出现 Complete! 则安装结束。

3、查看服务端版本 : rpm -qi mysql-server  ,能看到以下信息

	Name        : mysql-server                 Relocations: (not relocatable)
	Version     : 5.1.73                            Vendor: CentOS
	Release     : 8.el6_8                       Build Date: Fri Jan 27 06:25:43 2017
	Install Date: Wed Jun 21 11:13:02 2017         Build Host: c1bm.rdu2.centos.org
	Group       : Applications/Databases        Source RPM: mysql-5.1.73-8.el6_8.src.rpm
	Size        : 25884131                         License: GPLv2 with exceptions
	Signature   : RSA/SHA1, Fri Jan 27 06:35:28 2017, Key ID 0946fca2c105b9de
	Packager    : CentOS BuildSystem <http://bugs.centos.org>
	URL         : http://www.mysql.com
	Summary     : The MySQL server and related files
	
4、 首次启动mysql : service mysqld start  
	
	Initializing MySQL database:  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:

	/usr/bin/mysqladmin -u root password 'new-password'
	/usr/bin/mysqladmin -u root -h VM_102_32_centos password 'new-password'

	Alternatively you can run:
	/usr/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 /usr ; /usr/bin/mysqld_safe &

	You can test the MySQL daemon with mysql-test-run.pl
	cd /usr/mysql-test ; perl mysql-test-run.pl

	Please report any problems with the /usr/bin/mysqlbug script!				   [  OK  ]
	Starting mysqld:                                           [  OK  ]


5、设置开机启动  : chkconfig mysqld on

6、因为初次安装是没有密码的,默认用户是 root ,从上面语打印的信息可以看到,我们需要给root 用户设置一个密码 

   /usr/bin/mysqladmin -u root password 'new-password'
  
	只需要执行这句就可以 : mysqladmin -u root password '123456'  //123456 就是 root的密码

7、此时mysql 已经安装成功了,其他更详细的配置大家可以自己查资料了解,服务器一般不打开数据库的3306端口,如果需要工具远程连接数据库,可以试用ssh方式连接数据库

猜你喜欢

转载自my.oschina.net/u/3338455/blog/1805967