本章节主要讲解的是在虚拟机centOs7版本以上安装MysqL5.6版本,亲测可以直接使用,有需要帮助的小伙伴可以加本人[email protected]!!!!
卸载centOs7自带的mariadb命令:
rpm -qa | grep mariadb
rpm -e --nodeps 文件名
# yum list installed | grep MysqL
# yum -y remove 文件名
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(‘admin123‘) where user=‘root‘;
# flush privileges;
# exit;
9.查看MysqL是否自启动,并且设置开启自启动命令
# chkconfig --list | grep MysqLd # chkconfig MysqLd on
10.MysqL安全设置(系统会一路问你几个问题,看不懂复制之后翻译,基本上一路yes):
# MysqL_secure_installation
以下是讲解授权远程登录,以Navicat工具为主
授权远程访问:
登陆:
[[email protected] ~]# MysqL -uroot -p
Enter password:
Welcome to the MysqL monitor. Commands end with ; or \g.
Your MysqL connection id is 7
Server version: 5.5.60 MysqL Community Server (GPL) by Remi
copyright (c) 2000,2018,Oracle and/or its affiliates. All rights reserved.
Oracle is a registered Trademark of Oracle Corporation and/or its
affiliates. Other names may be Trademarks of their respective
owners.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
MysqL> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| fgf |
| MysqL |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.00 sec)
使用MysqL数据库(真正的数据库,而非数据库软件),将所有数据库的所有表(*.*)的所有权限(all privileges),授予通过任何ip(%)访问的root用户,密码为123456,最后刷新(flush privileges)即可。
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> 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)
开放防火墙端口:
先查看防火墙是否开启了3306端口:
1
|
firewall-cmd --permanent --query-port=3306
/tcp
|
打印结果如下:
no
表示没有开放3306端口,那么添加下该端口:
1
|
firewall-cmd --permanent --add-port=3306
/tcp
|
打印结果如下:
success
重新加载防火墙策略:
1
|
firewall-cmd --reload
|
执行成功后,查看10086端口是否被开启:
1
|
firewall-cmd --permanent --query-port=3306
/tcp
|
打印结果如下:
yes
最后一步配置虚拟机NAT设置(具体流程省略,主要是放行端口号)
在windows下,我用 navicat测试:
------MysqL 相关命令: service MysqLd restart ;service MysqLd status ;service MysqLd start