首先查看系统中有没安装mysql: rpm -qa|grep mysql
如果有,先命令删除:rpm -e --nodeps mysql-libs-5.1.66-2.el6_3.x86_64
安装开始:
1.下载mysql-5.5.28-linux2.6-i686.tar.gz包
2.
shell>groupadd mysql
shell>useradd -r -g mysql mysql
shell>cd /usr/local
shell>tar zxvf
shell>/path/to/mysql-VERSION-OS
.tar.gzln -s
shell>full-path-to-mysql-VERSION-OS
mysqlcd mysql
shell>chown -R mysql .
shell>chgrp -R mysql .
shell>scripts/mysql_install_db --user=mysql
shell>chown -R root .
shell>chown -R mysql data
# Next command is optional shell>cp support-files/my-medium.cnf /etc/my.cnf
shell>bin/mysqld_safe --user=mysql &
# Next command is optional shell>cp support-files/mysql.server /etc/init.d/mysql.server
3. 如果遇到libaio.so.1: cannot open mysql错误:
执行: yum install libaio
4.再安装client即可
5.修改root密码:
进入mysql数据库:update user set password=PASSWORD('123456') where user='root';
6.使root 能够远程登录:
进行授权操作:
mysql>GRANT ALL PRIVILEGES ON *.* TO
'root'
@
'%'
IDENTIFIED BY
'youpassword'
WITH GRANT OPTION;
重载授权表:
FLUSH PRIVILEGES;
7.修改user表,flush privileges后使root远程不能登录
注:如果停止不了mysql数据库,可以打掉3306商品的线程
卸载mysql:
1、查找以前是否装有mysql
命令:rpm -qa|grep -i mysql
可以看到mysql的两个包:
perl-DBD-MySQL-4.013-3.el6.x86_64
mysql-server-5.1.66-2.el6_3.x86_64
mysql-libs-5.1.66-2.el6_3.x86_64
qt-mysql-4.6.2-25.el6.x86_64
mysql-5.1.66-2.el6_3.x86_64
2、删除mysql
删除命令:rpm -e --nodeps 包名
( rpm -ev mysql-4.1.12-3.RHEL4.1 )
3.启动时如果报错:Starting MySQL... ERROR! The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid
解决办法:如果是空数据库,将data目录中的数据删除,再执行bin/mysqld --initialize --user=mysql