在centos6.5下面安装mysql5.5
reference web
http://www.tecmint.com/install-mysql-on-rhel-centos-6-5-fedora-17-12/
1. Remove the pre-installed mysql-libs with no dependecy.
rpm -e mysql-libs
rpm -e --nodeps mysql-libs
2. set rmi
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
3. check availability
yum --enablerepo=remi list mysql mysql-server
4. install mysql
yum --enablerepo=remi install mysql mysql-server
5. start/stop server
/etc/init.d/mysqld start /etc/init.d/mysqld stop /etc/init.d/mysqld status
#安装完成,更改root密码
mysql -u root mysql
#set password
UPDATE user SET Password=PASSWORD('root') WHERE user='root';
#change privilege
FLUSH PRIVILEGES;
#set any ip can connect
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
6. connecting to server
mysql -u root -p
---------------------------------------------------------------------
二、卸载掉原有mysql
因为mysql数据库在Linux上实在是太流行了,所以目前下载的主流Linux系统版本基本上都集成了mysql数据库在里面,我们可以通过如下命令来查看我们的操作系统上是否已经安装了mysql数据库
rpm -qa | grep mysql // 这个命令就会查看该操作系统上是否已经安装了mysql数据库
有的话,我们就通过 rpm -e 命令 或者 rpm -e --nodeps 命令来卸载掉
rpm -e mysql // 普通删除模式
rpm -e --nodeps mysql // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除
在删除完以后我们可以通过 rpm -qa | grep mysql 命令来查看mysql是否已经卸载成功!!
http://www.cnblogs.com/gaojian/archive/2013/09/12/3317000.html
cd /usr/local
tar -zxvf /home/hadoop/software/mysql-5.6.17-linux-glibc2.5-x86_64.tar.gz
ln -s mysql-5.6.17-linux-glibc2.5-x86_ls64 mysql
cd mysql
chown -R mysql .
chgrp -R mysql .
scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
#把mysql加到系统服务中
cp support-files/mysql.server /etc/init.d/mysql.server
#http://www.2cto.com/database/201304/205302.html
cp support-files/my-default.cnf ./my.cnf
把配置文件放到解压目录下,也可放到/etc/my.cnf,但是这里是免安装嘛,放本目录更好,呵呵
修改my.cnf,设置basedir datadir。
#http://blog.csdn.net/wyzxg/article/details/4720041
#ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
#由于mysql 默认的mysql.sock 是在/var/lib/mysql/mysql.sock,但linux系统总是去/tmp/mysql.sock查找,所以会报错
find / -name mysql.sock
为mysql.sock增加软连接(相当于windows中的快捷方式)。
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
cd /usr/local/mysql
bin/mysql --protocol=TCP -u root
#更改root密码
bin/mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('root') WHERE user='root';
FLUSH PRIVILEGES;
bin/mysql -u root -p
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;