1、
yum安装更方便
yum install wget
2、
新建文件夹
[root@localhost bin]# cd /usr/local/
[root@localhost local]# mkdir mysql
[root@localhost local]# cd mysql
[root@localhost mysql]#
3、
下载并安装MySQL官方的 Yum Repository
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum -y install mysql-community-server
4、
安装完成后查看版本号:mysql -V
5、
状态是 Active: active (running) ,说明启动成功
启动服务:
service mysqld restart
查看mysql运行状态:
systemctl status mysql.service
停掉mysql服务
service mysqld stop # 或者 systemctl stop mysql.service
6、
MySQL重置密码,先停掉mysql,以安全方式启动
systemctl stop mysql.service
以安全方式启动mysql:
/usr/bin/mysqld_safe --skip-grant-tables >/dev/null 2>&1 &
然后执行
/usr/bin/mysql -u root mysql
mysql> USER 'root'@'localhost' IDENTIFIED BY '123456'
7、
登陆mysql,试试是否成功:
mysql -u root -p
8、查看MySQL端口号
show variables like 'port';
9、
授权远程连接
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '123456' WITH GRANT OPTION
10、
开放3306端口:
firewall-cmd --add-port=3306/tcp --permanent
firewall-cmd --add-port=3306/udp --permanent
firewall-cmd --reload