安装环境:系统是 centos6.5
下载地址:http://dev.mysql.com/downloads/mysql/5.6.html#downloads
下载版本:我这里选择的5.6.33,通用版,linux下64位
也可以直接复制64位的下载地址,通过命令下载:wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
tar -zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
cp -r mysql-5.6.33-linux-glibc2.5-x86_64 /usr/local
mv /usr/local/mysql-5.6.33-linux-glibc2.5-x86_64 /usr/local/mysql
groupadd mysql
useradd -g mysql mysql
cd到msql目录
cd /usr/local/mysql/
创建目录data.mysql
mkdir ./data/mysql
将mysql目录的拥有者指定给mysql组的mysql chown [选项]... [所有者][:[组]] 文件...
chown -R mysql:mysql ./
./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql
将mysql加入服务,命名为mysqld
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
cp support-files/my-default.cnf /etc/my.cnf
出现如下异常:
FATAL ERROR: please install the following Perl modules before executing /usr/bin/mysql_install_db:
Data:Dumper
yum install -y perl-Module-Install.noarch
vi /etc/init.d/mysqld
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/mysql
service mysqld start
chkconfig mysqld on(开机自启mysql,自启之后,下次打开Linux就不需要再启动mysqld服务了)
到mysql bin目录
mysql -u root -p 第一次可直接进去
修改root密码
set password for 'root'@'localhost'=password('123456');
export PATH=$PATH:/usr/local/mysql/bin
source /etc/profile
service mysqld start
service mysqld stop
service mysqld status
5.1 sqlyog连接时,报1130错误,是由于没有给远程连接的用户权限问题
解决1:更改 ‘mysql’数据库‘user’表‘host’项,从‘localhost’改成‘%’。
use mysql;
select 'host' from user where user='root';
update user set host = '%' where user ='root';
flush privileges;
解决2:直接授权(常用)进入mysql
GRANT ALL PRIVILEGES ON *.* TO ‘root’@'%’ IDENTIFIED BY ‘youpassword’ WITH GRANT OPTION;
5.2 安装时的一些错误
-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
6.1 配置环境变量
vi + /etc/profile
export PATH=…:/usr/local/mysql/bin
6.2 如果在外面访问需要关闭防火墙
关闭防火墙命令:systemctl stop firewalld.service
开启防火墙:systemctl start firewalld.service
关闭开机自启动:systemctl disable firewalld.service
开启开机启动:systemctl enable firewalld.service