1、上传文件并进行解压
cd /usr/local
tar -zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
2、重命名
mv mysql-5.6.33-linux-glibc2.5-x86_64 mysql
3、添加用户和用户组
groupadd mysql
useradd -g mysql mysql
4、安装
cd /usr/local/mysql/
mkdir ./data/mysql
chown -R mysql:mysql ./
./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
cp support-files/my-default.cnf /etc/my.cnf
5、修改启动脚本
vi /etc/init.d/mysqld
#修改项:
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/mysql
6、启动服务
service mysqld start
7、加入环境变量
vi /etc/profile
增加内容:
export PATH=$PATH:/usr/local/mysql/bin
生效内容
source /etc/profile
8、测试连接
cd /usr/local/mysql
bin/mysql -uroot
进入mysql中
mysql> use mysql
mysql> update user set password=PASSWORD("root")where User="root";
mysql> flush privileges;
mysql> quit
9、验证安装成功
mysql -uroot -proot
#(执行下面的语句*.*:所有库下的所有表 %:任何IP地址或主机都可以连接)
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
Mysql>FLUSH PRIVILEGES;
10、安装中出现错误问题
-bash: ./scripts/mysql_install_db: /usr/bin/perl: bad interpreter: 没有那个文件或目录
解决: yum -y install perl perl-devel
Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
解决:yum -y install libaio-devel