码迷,mamicode.com
首页 > 数据库 > 详细

转:linux CentOS6.5 yum安装mysql 5.6

时间:2018-03-25 15:52:37      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:start   row   load   warning   buffer   数据   starting   release   let   

按:下面文章经过我一路测试没有问题,是篇好文,在此感谢作者 别踩我袈裟  。另我在后面加上了自己添加的内容。

出处:https://www.cnblogs.com/renjidong/p/7047396.html

1.新开的云服务器,需要检测系统是否自带安装mysql

# yum list installed | grep mysql

2.如果发现有系统自带mysql,果断这么干

# yum -y remove mysql-libs.x86_64


3.随便在你存放文件的目录下执行,这里解释一下,由于这个mysql的yum源服务器在国外,所以下载速度会比较慢,还好mysql5.6只有79M大,而mysql5.7就有182M了,所以这是我不想安装mysql5.7的原因

# wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm


4.接着执行这句,解释一下,这个rpm还不是mysql的安装文件,只是两个yum源文件,执行后,在/etc/yum.repos.d/ 这个目录下多出mysql-community-source.repo和mysql-community.repo

# rpm -ivh mysql-community-release-el6-5.noarch.rpm


5.这个时候,可以用yum repolist mysql这个命令查看一下是否已经有mysql可安装文件

#yum repolist all | grep mysql


6.安装mysql 服务器命令(一路yes):

# yum install mysql-community-server


7.安装成功后

# service mysqld start


8.由于mysql刚刚安装完的时候,mysql的root用户的密码默认是空的,所以我们需要及时用mysql的root用户登录(第一次回车键,不用输入密码),并修改密码

# mysql -u root
# use mysql;
# update user set password=PASSWORD(‘123456‘) where User=‘root‘;
# flush privileges;


9.查看mysql是否自启动,并且设置开启自启动命令

# chkconfig --list | grep mysqld
# chkconfig mysqld on
10.mysql安全设置(系统会一路问你几个问题,看不懂复制之后翻译,基本上一路yes):

# mysql_secure_installation

以下为我个人添加的内容:

进入mysql数据库管理控制台
#./mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.0.67 Source distribution

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the buffer.

mysql> grant all privileges on *.* to root@‘%‘ identified by "root";
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> grant select,update,insert,delete on *.* to root@192.168.0.100 identified by "root";
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye

上面的步骤是进行授权

然后重启mysqld服务
service mysqld restart
Stopping MySQL:                                            [  OK  ]
Starting MySQL:                                            [  OK  ]

再次进入mysql管理控制台(修改密码这一步不可或缺,否则容易出现“access denied for user root @localhost”错误
mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.67 Source distribution

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the buffer.

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set password=password(‘12345678‘) where user=‘root‘;
Query OK, 5 rows affected (0.00 sec)
Rows matched: 5  Changed: 5  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye

以上步骤是修改root用户的密码

之后开启防火墙的3306端口
vi /etc/sysconfig/iptables

以下是/etc/sysconfig/iptables的内容,其中蓝色一行是新加的。这一行可以由上一行复制得到,方法是在22哪行按下yy,然后按p,然后点insert键进入编辑模式,修改22为3306,然后点esc,输入wq保存退出。
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

防火墙重启
service iptables restart
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]

之后就可以在终端上敲#ifconfig,找出虚拟机对应的ip地址,比如说是192.168.0.100,然后就可以用mysqlfront或程序连接数据库了。

 2018年3月25日14点41分

转:linux CentOS6.5 yum安装mysql 5.6

标签:start   row   load   warning   buffer   数据   starting   release   let   

原文地址:https://www.cnblogs.com/xiandedanteng/p/8644429.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!