centos服务器搭建-MySQL-Binaries-5.6.35

http://blog.csdn.net/kk185800961/article/details/44118323

https://dev.mysql.com/doc/refman/5.7/en/binary-installation.html

ftp://ftp.stu.edu.tw/pub

linux安装mysql服务分两种安装方法:

MySQL一般3种模式安装:RPM,二进制,源码

RPM

rpm -ivhMySQL-server-5.6.35-1.el7.x86_64.rpm

二进制

mysql-VERSION-OS.tar.gz(如:mysql-5.6.23-Linux.tar.gz)

源码

MySQL-5.6.22-1.linux_glibc2.5.src.rpm

 

下载安装配置

 

groupaddmysql

useradd -r -g mysql -s /sbin/false  mysql

cd    /opt

wget  http://ftp.iij.ad.jp/pub/db/mysql/Downloads/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz

tar -zxvfmysql-5.6.35-linux-glibc2.5-x86_64.tar.gz

mv   mysql-5.6.35-linux-glibc2.5-x86_64   /usr/local/mysql

/usr/local/mysql/scripts/mysql_install_db  --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data     --user=mysql --random-passwords

 

mkdir /usr/local/mysql/log

vim /usr/local/mysql/log/error.log

:wq

 

chown -R mysql:mysql    /usr/local/mysql/

chown -R mysql:mysql    /usr/local/mysql/data/

chown -R mysql:mysql    /usr/local/mysql/log

 

cp  -f  /usr/local/mysql/support-files/mysql.server    /etc/init.d/mysqld

sed -i 's#^basedir=$#basedir= /usr/local/mysql#' /etc/init.d/mysqld

sed -i 's#^datadir=$#datadir= /usr/local/mysql/data#' /etc/init.d/mysqld

chmod 755/etc/init.d/mysqld

 

rm -rf    /etc/my.cnf

cp  -f /usr/local/mysql/support-files/my-default.cnf   /etc/my.cnf

echo "basedir =/usr/local/mysql" >> /etc/my.cnf

echo "datadir =/usr/local/mysql/data" >> /etc/my.cnf

echo "port = 3306" >> /etc/my.cnf

echo "server_id = 1" >> /etc/my.cnf

echo "datadir =/usr/local/mysql/data" >> /etc/my.cnf

echo "expire_logs_days = 5" >> /etc/my.cnf

echo "max_binlog_size = 1000M" >> /etc/my.cnf

echo "log-error=/usr/local/mysql/log/error.log" >>/etc/my.cnf

ln -s /usr/local/mysql/bin/mysql /usr/bin

 

打开/etc/selinux/config,把SELINUX=enforcing改为SELINUX=disabled

root@localhost mysql]# vim   /root/.mysql_secret

# The randompassword set for the root user at Thu Feb 16 17:54:13 2017 (local time):dJbXQMj9A4RjsOyq

 

~                                                                                                                                          

~                                                                             

[root@localhost init.d]# service mysqld start

/etc/init.d/mysqld:line 46: /usr/local/mysql: Is a directory

/etc/init.d/mysqld:line 47: /usr/local/mysql/data: Is a directory

Starting MySQL..SUCCESS!

启动mysqld服务的另一种方法(安装完成的提示中):

/usr/local/mysql/bin/mysqld_safe&

#这是在Unix和NetWare中推荐启动mysqld服务的启动文件。

 

设置mysql的root密码,为了安全,建议使用mysql_secure_installation来设置(安装完成的提示中):

[root@localhostdata]# /usr/local/mysql/bin/mysql_secure_installation

 

NOTE: RUNNING ALLPARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL

      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

 

In order to log intoMySQL to secure it, we'll need the current

password for theroot user.  If you've just installedMySQL, and

you haven't set theroot password yet, the password will be blank,

so you should justpress enter here.

 

Enter current password for root (enter for none):      #若已设置root密码,则输入,否则留空

OK, successfullyused password, moving on...

 

Setting the rootpassword ensures that nobody can log into the MySQL

root user withoutthe proper authorisation.

 

You already have aroot password set, so you can safely answer 'n'.

 

Change the root password? [Y/n] Y     #是否改变root密码?

New password: beijing520

Re-enter newpassword: beijing520

Password updatedsuccessfully!

Reloading privilegetables..

 ... Success!

 

By default, a MySQLinstallation has an anonymous user, allowing anyone

to log into MySQLwithout having to have a user account created for

them.  This is intended only for testing, and tomake the installation

go a bitsmoother.  You should remove them beforemoving into a

productionenvironment.

 

Remove anonymous users? [Y/n] Y        #是否移除匿名用户?

 ... Success!

 

Normally, rootshould only be allowed to connect from 'localhost'.  This

ensures that someonecannot guess at the root password from the network.

 

Disallow root login remotely? [Y/n] n     #是否禁止root远程登录?

 ... skipping.

 

By default, MySQLcomes with a database named 'test' that anyone can

access.  This is also intended only for testing, andshould be removed

before moving into aproduction environment.

 

Remove test database and access to it? [Y/n] n        #是否移除测试数据库?

 ... skipping.

 

Reloading theprivilege tables will ensure that all changes made so far

will take effectimmediately.

 

Reload privilege tables now? [Y/n] y             #是否重新加载权限表?

 ... Success!

 

 

All done!  If you've completed all of the above steps,your MySQL

installation shouldnow be secure.

 

Thanks for usingMySQL!

 

 

Cleaning up...

 

[root@localhost /]# lsof -i:3306

COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

mysqld  11204 mysql  10u  IPv6  59656     0t0  TCP *:mysql (LISTEN)

[root@localhost /]# service mysqld status

 SUCCESS! MySQL running (11204)

 

开启mysql远程连接

mysql   -uroot  -pbeijing520

>select host,user,password from user;

>grant   all  on    *.*   to  root@"%"  identified   by   "beijing520";

>select host,user,password from user;

>flush privileges;

>quit;

 

##Add

firewall-cmd   --permanent   --zone=public   --add-port=80/tcp

firewall-cmd   --permanent   --zone=public   --add-port=8080/tcp

 firewall-cmd --permanent --zone=public--add-port=3306/tcp

 firewall-cmd --permanent--zone=public --add-port=9444/tcp

##Remove

firewall-cmd   --permanent   --zone=public   --remove-port=80/tcp

##Reload

firewall-cmd   --reload

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值