Because the previous use of Ubuntu is rarely used CentOS, today needs to install a database, the spirit of rapid resolution of this need to start installing MySQL, but look at a lot of information, finally did not succeed, one hours is really enough, and finally humbly ask friends, Finally see starting MySQL ..... success!
Don't say much nonsense, start now. Also deepened their impressions. Can not always apt-get down, CentOS do not let you engage.
One: the preparatory work
Configure the firewall to turn on port 3306
[Email protected] ~]# Vi/etc/sysconfig/iptables
-A input-m state--state new-m tcp-p TCP--dport 22-j ACCEPT #这条默认是有的.
-A input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT #也不知道为什么这条添加在22这条后面.
Restart the firewall so that its configuration takes effect:
[Email protected] ~]#/etc/init.d/iptables restart
To turn off SELinux:
[Email protected] ~]# Vi/etc/selinux/config
Add the following information later:
Selinux=disable
Save exit.
View current Version information:
[Email protected] ~]# Rpm-qa | grep MySQL
If any, uninstall
Uninstall command: [[email protected] ~] #yum-y Remove (database name)
Two: Install CMake, for MySQL compile tool
Direct Full Installation:
[Email protected] src]# cd/usr/local/src/
[[email protected] src] #yum install cmake ncurses5-devel gcc g++ bison OpenSSL openssl-devel ncurses ncurses-devel gcc-c++ -Y
Continue after installation:
Three: Official Installation:
Download MySQL version
[Email protected] src]# wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.27.tar.gz
[[email protected] src] #tar zxvf mysql-5.5.27.tar.gz
[[email protected] src] #cd/usr/local/mysql
Install the Ncurses-devel package and the Bison package, if there is no need to install the
[[email protected] MySQL] #yum install Ncurses-devel
[[email protected] MySQL] #yum install Bison
To configure a user group:
[[email protected] mysql-5.5.27] #groupadd MySQL #添加mysql用户组
[[email protected] mysql-5.5.27] #useradd-g MySQL mysql-s/bin/false #创建mysql用户 and added to the MySQL group, not allowing MySQL users to log in directly to the system
[[email protected] mysql-5.5.27] #mkdir-P/data/mysql #创建数据库存放目录
[email protected] mysql-5.5.27]#chown-r mysql:mysql/data/mysql/#设置数据库目录权限
[email protected] mysql-5.5.27]#mkdir-p/usr/local/mysql #设置安装目录
[email protected] mysql-5.5.27]#cmake. -dcmake_install_prefix=/usr/local/mysql-dmysql_datadir=/data/mysql-dsysconfdir=/etc
[[email protected] mysql-5.5.27]#make && make install
Waiting for installation
Four: Configuration
[[email protected] mysql-5.5.27] #cd/usr/local/mysql
[[email protected] mysql]#CP./SUPPORT-FILES/MY-HUGE.CNF/ETC/MY.CNF #拷贝配置文件, overwrite if present
[[email protected] mysql]#vi/etc/my.cnf #编辑, add a line under [Mysqld]
DataDir =/data/mysql
[email protected] mysql]#/scripts/mysql_install_db--user=mysql #生成mysql系统数据库
[email protected] mysql]#CP./SUPPORT-FILES/MYSQL.SERVER/ETC/RC.D/INIT.D/MYSQLD #把mysql加入系统启动
[email protected] mysql]#chmod 755/etc/init.d/mysqld #增加执行权限
[[email protected] INIT.D] #chkconfig mysqld on #加入开机启动
[[email protected] INIT.D] #vi/etc/rc.d/init.d/mysqld #编辑
Basedir=/usr/local/mysql #mysql程序安装路径
Datadir=/data/mysql #mysql数据存放vi Path
[[email protected] MySQL] #service mysql start #启动
#成功提示: Starting MySQL ..... success!
Adding the MySQL service to the system environment variable
[[email protected] MySQL] #vi/etc/profile
Add: Export path= $PATH: $JAVA _home/bin:/usr/local/mysql/bin
[[email protected] MySQL] #source/etc/profile #生效
Five: Set password
[Email protected] mysql]#./mysqladmin-u root password root #设置成功
[[email protected] MySQL] #service mysql restart #重启
[[email protected] MySQL] #mysql-u root-p root #进入mysql
Enter Password: #输入密码
Install MySQL documentation for centos6.5 above.
This article is from the "Bug Happy" blog, please make sure to keep this source http://bughapply.blog.51cto.com/744579/1833488
centos6.5 installation mysql-5.5