1、首先下载,命令行直接下载:
下载地址: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
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、
#添加用户组
groupadd mysql
#添加用户mysql 到用户组mysql
useradd
-g mysql mysql
4、安装
cd /usr/local/mysql/
mkdir ./data/mysql
chown -R mysql:mysql ./
./scripts/mysql_install_db --安装
mkdir ./data/mysql
chown -R mysql:mysql ./
./scripts/mysql_install_db --安装
----------------#解决方法:
yum install -y perl-Data-Dumper
yum install -y perl-Data-Dumper
出现下面情况:
linux libaio.so.1: cannot open shared object file: No such file or directory
缺少安装包libaio和libaio-devel.
命令行
yum install libaio*。自动安装这两个包
linux libaio.so.1: cannot open shared object file: No such file or directory
缺少安装包libaio和libaio-devel.
命令行
yum install libaio*。自动安装这两个包
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
8、修改当前目录拥有者为root用户
chown -R root:root ./
9、修改当前data目录拥有者为mysql用户
chown -R mysql:mysql data
10、添加mysql服务开机自启动
添加开机启动,把启动脚本放到开机初始化目录。
cp support-files/mysql.server /etc/init.d/mysql
# 赋予可执行权限
chmod +x /etc/init.d/mysql
# 添加服务
chkconfig --add mysql
# 显示服务列表
chkconfig --list
如果看到mysql的服务,并且3,4,5都是on的话则成功,如果是off,则执行
设置root 密码:
set password for root@localhost = password('root12345');
12、设置远程客户端连接mysql
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.100' IDENTIFIED BY '' WITH GRANT OPTION;
mysql> -- @'192.168.1.100'可以替换为@‘%’就可任意ip访问,当然我们也可以直接用 UPDATE 更新 root 用户 Host, 但不推荐, SQL如下:
mysql> -- UPDATE user SET Host='192.168.1.100' WHERE User='root' AND Host='localhost' LIMIT 1;
mysql> flush privileges; --该句一定要有,才能生效;
13、修改root密码
mysql> use mysql
Database changed
mysql> update user
set
password=PASSWORD(
'123456'
)
where
user=
'root'
;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
14、创建数据库
CREATE DATABASE 库名;