MySQL在linux下的安装(亲测可行)
安装环境:系统是 centos6.5
1. 下载
#我这里选择的5.6.33,通用版,linux下64位
http://dev.mysql.com/downloads/mysql/5.6.html#downloads
#也可以直接复制64位的下载地址,通过命令下载
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
2. 解压
#解压
tar -zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
#复制解压后的mysql目录
cp-r mysql-5.6.33-linux-glibc2.5-x86_64 /usr/local/mysql
3. 安装
#切换到local下的mysql目录
cd /usr/local/mysql/
#切换之后,在data下创建mysql目录
mkdir ./data/mysql
#将local下的mysql目录的所有权改为 mysql用户组下的mysql用户(所有者:组)
chown -R mysql: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
#修改启动脚本
vi /etc/init.d/mysqld
#修改项:
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/mysql
#启动服务
service mysqld start
#测试连接
./mysql/bin/mysql -uroot
#加入环境变量,编辑 /etc/profile,这样可以在任何地方用mysql命令了
export PATH=$PATH:/usr/local/mysql/bin
source /etc/profile
#启动mysql
service mysqld start
#关闭mysql
service mysqld stop
#查看运行状态
service mysqld status
4. 问题
4.1 sqlyog连接时,报1130错误,是由于没有给远程连接的用户设置权限
#错误信息
ERROR 1130: Host xxx.xxx.xxx.xxx is not allowed to connect to this MySQL server
#方式1:myuser使用mypassword从任何主机连接到mysql服务器
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
#方式2::允许用户myuser从ip为192.168.100.10的主机连接到mysql服务器,并使用mypassword作为密码
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.100.10' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
#方式3::允许用户myuser从ip为192.168.100.10的主机连接到mysql服务器的order数据库,并使用mypassword作为密码
GRANT ALL PRIVILEGES ON order.* TO 'myuser'@'192.168.100.10' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;