1. 下载二进制mysql的安装包
[root@localhost ~]#cd /usr/local
[root@localhost /usr/local]#wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.42-linux-glibc2.12-x86_64.tar.gz
如果下载不了可以去官网下载gz包 然后上传到 /usr/local目录
2. 解压压缩文件
[root@localhost /usr/local]#tar -zxvf mysql-5.6.42-linux-glibc2.12-x86_64.tar.gz
3. 修改名称
[root@localhost /usr/local]# mv mysql-5.6.42-linux-glibc2.12-x86_64 mysql
4. 进入目录
[root@localhost /usr/local]# cd mysql/
5. 拷贝服务的模板文件
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld
6. 拷贝my.cnf配置模板
[root@localhost mysql]# cp support-files/my-default.cnf /etc/my.cnf
7. 修改两个参数,稍后用作数据目录和mysql安装目录
[root@localhost mysql]# vi /etc/init.d/mysqld
#If you change base dir, you must also change datadir. These may get
overwritten by settings in the MySQL configuration files.
basedir=/usr/local/mysql
datadir=/data/mysql
8. 新建上面的mysql数据目录
[root@localhost mysql]# mkdir /data
9. 软连接mysql安装目录
[root@localhost mysql]# ln -s /services/current_apps/mysql-5.6.42-linux-glibc2.12-x86_64/ /usr/local/mysql
10. 初始化mysql的数据目录
[root@localhost mysql]# ./scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql –datadir=/data/mysql
11. 把mysqld服务加入服务启动
[root@localhost mysql]# chkconfig –add mysqld
12.启动mysqld 服务,显示success表示成功
[root@localhost mysql]# service mysqld start
Starting MySQL.Logging to ‘/data/mysql/minion-1.err‘.
… SUCCESS!
13 确认服务mysql的确开启,返回1说明开了
[root@minion-1 mysql]# netstat -tupln|grep 3306|wc -l
1
14 配置远程连接
14.1 访问mysql
[root@localhost mysql]mysql
14.2 切换数据库
mysql> use mysql;
14.3 配置远程访问
mysql>
GRANT
ALL
PRIVILEGES
ON
*.*
TO
'root'
@
'%'
IDENTIFIED
BY
'123456'
WITH
GRANT
OPTION
;
这里123456 是你的密码
14.4 刷新修改
mysql>FLUSH RIVILEGES;
执行完成就可以了 输入 exit 退出
14.5 开启3306端口
[root@localhost mysql] /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
本文地址:https://blog.csdn.net/pkpengzai2014/article/details/110534581