CentOS7下安装mysql5.6

1.CentOS7下安装mysql步骤:

(1)首先必须添加mysql社区repo通过输入命令:

#centos7
sudo rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
#centos6
sudo rpm -Uvh http://repo.mysql.com/yum/mysql-5.6-community/el/6/x86_64/mysql-community-release-el6-5.noarch.rpm




(2)使用yum方式安装mysql:

yum install mysql mysql-server mysql-libs mysql-server

#报错: Requires: systemd
# yum remove zabbix-release
# yum install http://repo.mysql.com/yum/mysql-5.6-community/el/6/x86_64/mysql-community-release-el6-5.noarch.rpm
# yum clean all

(3)启动 / 停止mysql:

service mysqld start / stop 或者 systemctl start mysqld.service

#报错MySQL Daemon failed to start. Starting mysqld: [FAILED]
#rm -fr /var/lib/mysql/*
#rm /var/lock/subsys/mysqld
#killall mysqld

(4)查看启动状态:

service mysqld status

######################################### 以下操作容易出问题 设置密码可以在mysql_secure_installation里设置;
(1)登录mysql,初始登录不需要密码:

mysql -uroot -p

(2)切换数据库至mysql:

use mysql;

(3)修改mysql root用户密码:

update user set password=password(‘Sincere1112‘) where user=‘root‘;

(4)修改允许外部远程访问:

UPDATE user SET Host = ‘%‘ WHERE User= ‘root‘ LIMIT 1;

(5)输入如下命令让刚才设置的命令生效:

flush privileges;

(6)最后使用exit退出mysql服务即可。
############################################################################
九、启动mysql

systemctl start mysqld

十、设置mysql密码,因为初始密码是没有的,所以你得设置一个
mysql_secure_installation;    #按照提示操作即可


十一、添加3306端口访问权限 华为云网页操作

firewall-cmd --permanent --zone=public --add-port=3306/tcp     #添加tcp协议入口
firewall-cmd --permanent --zone=public --add-port=3306/udp

如果提示firewall(防火墙)没有打开,可以打开

systemctl start firewalld     #打开后再进行上面的设置

十二、设置mysql root 访问权限 navicat远程访问权限
grant all privileges on *.* to root@‘%‘identified by ‘passwd‘;
flush privileges;
reboot

CentOS7下安装mysql5.6

上一篇:linux备份和mysql登陆自动输入密码


下一篇:移动端 canvas基础1