2.CentOS 7.3服务器环境搭建-mysql数据库搭建
2017-04-13 17:09
302 查看
1.首先下载必备的命令。
vim命令(https://www.oschina.net/news/43167/130-essential-vim-commands)
安装命令:yum -y install vim*
wget命令:yum -y install wegt
2.使用国内镜像源,本人用的是阿里的镜像。(
网易开源镜像站:http://mirrors.163.com/
中科大的Linux安装镜像源:http://centos.ustc.edu.cn/
搜狐的Linux安装镜像源:http://mirrors.sohu.com/
北京首都在线科技:http://mirrors.yun-idc.com/
)
1.cd /etc/yum.repos.d/Centos-Base.repo
2.先拷贝这个文件:mv Centos-Base.repo
Centos-Base.repo.copy
3.wget
-o Centos-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo。
(根据你的服务器版本下载
Centos-5,6,7)
4.刷新缓存:yum
makecache
SUCCESS!
3.下载安装mysql数据库
1.切换到opt目录下载mysql安装包
cd
opt/mysql
wget http://repo.mysql.com/mysql57-community-release-el7-9.noarch.rpm(下载mysql一路y下去) href="http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm" target=_blank>
yum
install mysql-server (安装mysql服务)
2.这时候检查mysql是否启动
/bin/systemctl status mysqld.service
若没启动输入/bin/systemctl start mysqld.service
然后获得root登录密码:
grep "password" /var/log/mysqld.log
2017-04-14T11:36:20.585006Z
1 [Note] A temporary password is generated for root@localhost: Qk<U,b6!eOm<
3.用初始密码登录mysql
[root@localhost
log]# 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.7.18
Copyright (c) 2000, 2017, 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.
登录成功!
接着更改登录密码!这初始密码太坑爹了,肯定要改。。。
但是mysql5.7的密码采用了密码强度验证插件
validate_password ,密码也得设计的超级复杂。。
mysql> set password=password('密码');
设置任何ip下可以访问:
mysql>
grant all privileges on *.* to root@"%" identified by "密码";
刷新权限
flush privileges;
启动 MySQL 服务:
service mysqld start
关闭 MySQL 服务:
service mysqld stop
重启 MySQL 服务:
service mysqld restart
查看 MySQL 的状态:
service mysqld status
设置mysql字符集:
打开etc/my.cnf
[client]
default-character-set=utf8
[mysqld]
character_set_server=utf8
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
重启数据库,即可生效。
4.用Navicat连接Mysql的连接不上,开启系统防火墙
systemctl stop firewalld
vim命令(https://www.oschina.net/news/43167/130-essential-vim-commands)
安装命令:yum -y install vim*
wget命令:yum -y install wegt
2.使用国内镜像源,本人用的是阿里的镜像。(
网易开源镜像站:http://mirrors.163.com/
中科大的Linux安装镜像源:http://centos.ustc.edu.cn/
搜狐的Linux安装镜像源:http://mirrors.sohu.com/
北京首都在线科技:http://mirrors.yun-idc.com/
)
1.cd /etc/yum.repos.d/Centos-Base.repo
2.先拷贝这个文件:mv Centos-Base.repo
Centos-Base.repo.copy
3.wget
-o Centos-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo。
(根据你的服务器版本下载
Centos-5,6,7)
4.刷新缓存:yum
makecache
SUCCESS!
3.下载安装mysql数据库
1.切换到opt目录下载mysql安装包
cd
opt/mysql
wget http://repo.mysql.com/mysql57-community-release-el7-9.noarch.rpm(下载mysql一路y下去) href="http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm" target=_blank>
yum
install mysql-server (安装mysql服务)
2.这时候检查mysql是否启动
/bin/systemctl status mysqld.service
若没启动输入/bin/systemctl start mysqld.service
然后获得root登录密码:
grep "password" /var/log/mysqld.log
2017-04-14T11:36:20.585006Z
1 [Note] A temporary password is generated for root@localhost: Qk<U,b6!eOm<
3.用初始密码登录mysql
[root@localhost
log]# 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.7.18
Copyright (c) 2000, 2017, 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.
登录成功!
接着更改登录密码!这初始密码太坑爹了,肯定要改。。。
但是mysql5.7的密码采用了密码强度验证插件
validate_password ,密码也得设计的超级复杂。。
mysql> set password=password('密码');
设置任何ip下可以访问:
mysql>
grant all privileges on *.* to root@"%" identified by "密码";
刷新权限
flush privileges;
启动 MySQL 服务:
service mysqld start
关闭 MySQL 服务:
service mysqld stop
重启 MySQL 服务:
service mysqld restart
查看 MySQL 的状态:
service mysqld status
设置mysql字符集:
打开etc/my.cnf
[client]
default-character-set=utf8
[mysqld]
character_set_server=utf8
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
重启数据库,即可生效。
4.用Navicat连接Mysql的连接不上,开启系统防火墙
systemctl stop firewalld
相关文章推荐
- Linux---VMware 虚拟机安装 CentOS 7.3、配置JDK环境、Tomcat服务器、MySQL数据库
- Centos7.3服务器搭建LNMP环境的方法
- Centos6.3服务器环境的搭建
- Centos6.4环境下DNS服务器的搭建
- 在CentOS上搭建PHP服务器环境
- Centos6.5环境下搭建svn服务器
- CentOS6.5安装mysql cluster7.3.7 搭建mysql数据库集群环境
- 搭建Web服务器之Step6:CentOS6.3安装JDK和环境配置
- CentOS服务器下JavaEE环境搭建指南(远程桌面+JDK+Tomcat+MySQL)
- 从零搭建LNMP环境(三) - 安装MySQL数据库服务器
- Centos6.4环境下DNS服务器的搭建
- Cacti监控服务器配置教程(基于CentOS+Nginx+MySQL+PHP环境搭建)
- 在CentOS上搭建PHP服务器环境
- centos 搭建php服务器环境
- centos搭建nginx+php+mysql环境(高于apeche10的服务器)
- centos环境搭建java web,mysql,ftp服务器环境
- 在CentOS上搭建apache和PHP服务器环境(转)
- 在CentOS上搭建PHP服务器环境
- CentOS 环境利用 Nginx搭建服务器下载功能
- 在CentOS上搭建PHP服务器环境