#查看是否已经安装mysql 如果有则删除
rpm -qa|grep -i mysql
rpm -ev mysql-libs-*
rpm -ev mysql-server-5.1.73-3.el6_5.i686
rpm -ev mysql-devel-5.1.73-3.el6_5.i686
#解压
tar -zxvf mysql-5.5.33-linux2.6-i686.tar.gz
mv mysql-5.5.33-linux2.6-i686 /application/mysql
cd /application/mysql/
#创建用户和用户组
groupadd mysql
useradd mysql -g mysql -M -s /sbin/nologin
#给data目录授权
chown -R mysql.mysql /application/mysql/data
#初始化mysql
./scripts/mysql_install_db --user=mysql --basedir=/application/mysql/ --datadir=/application/mysql/data/
#没有错误的话进行下一步
\cp support-files/mysql.server /etc/init.d/mysqld
vim /etc/init.d/mysqld
basedir=/application/mysql
datadir=/application/mysql/data
cp support-files/my-small.cnf /etc/my.cnf
/etc/init.d/mysqld start
/etc/init.d/mysqld stop
/application/mysql/bin/mysqladmin -u root password '123456'
进入mysql库
/application/mysql/bin/mysql
或者添加到mysql命令
本文来自博客园,作者:孙龙-程序员,转载请注明原文链接:https://www.cnblogs.com/sunlong88/p/8672171.html