1.安装mysql5.6依存包
2.下载编译包
wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
tar xvf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
注:-bash: wget: command not found的两种解决方法
3.复制到指定目录
mv mysql-5.6.35-linux-glibc2.5-x86_64 /usr/local/mysql
4.创建mysql用户和组
groupadd mysql
useradd -r -g mysql mysql -d /usr/local/mysql
passwd mysql
5.修改目录权限
chown -R mysql:mysql /usr/local/mysql
6.安装数据库
su mysql
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
exit
注1:这里可能会报错:scripts/mysql_install_db: /usr/bin/perl: bad interpreter: No such file or directory。
需要安装perl以及perl-devel.执行命令:yum –y install perl perl-devel
参考:CentOS 安装Perl环境
注2:如果安装perl环境报错,执行make命令报错,No targets specified and no makefile found, 是缺少ncurses安装包造成的。请参考make: *** No targets specified and no makefile found. Stop.解决方法 或者 liunx下安装mysql,make时 *** No targets specified and no makefile found. stop.
注3:如果安装ncurses安装包报错:configure: error: no acceptable C compiler found in $PATH,没找到可用的C编译器,可能是你GCC没装吧,装了GCC就行了。安装命令:
# yum install gcc gcc-c++ autoconf automake
参考:redhat 5下安装阿帕奇出现make: *** No targets specified and no makefile found. Stop.
7.复制mysql配置文件
cd /usr/local/mysql/support-files
cp my-default.cnf /etc/my.cnf
8.添加系统服务
cp mysql.server /etc/init.d/mysql
chkconfig mysql on
9.添加环境变量
vi /etc/profile
在最下面添加
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin
保存退出后,执行生效代码
. /etc/profile
10.启动mysql
service mysql start
11.设置root密码
mysqladmin -u root password '123456'
12.设置默认端口
vi /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
port=3306
server_id=1
socket=/tmp/mysql.sock
13.允许所有外部链接访问(可选)
mysql -u root -p
mysql命令行输入
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
FLUSH PRIVILEGES;
总结:耗时一个下午完成安装,遇到很多错误,看日志发现问题并解决。耐心!!!
参考:
CentOS6.8手动安装MySQL5.6
MySQL [ERROR] Table 'mysql.user' doesn't exist
Linux(Centos7)yum安装最新mysql
CentOS6.8下使用yum安装mysql,并远程登陆mysql
记一次完整的Tomcat服务器搭建及项目部署过程
yum提示Another app is currently holding the yum lock; waiting for it to exit...
centos彻底删除文件夹、文件命令
重点推荐:mysql5.6 linux下安装笔记