linux 利用yum源安装mysql5.7
前言
- CentOS 7
- MySQL 5.7
- 查找mysql源 http://repo.mysql.com
步骤
添加mysql源
shell> rpm -ivh http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm Retrieving http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm Preparing... ################################# [100%] Updating / installing...1:mysql57-community-release-el7-10 ################################# [100%]
注:卸载mysql源
rpm -e --nodeps mysql57-community-release-el7-10.noarch
查看mysql源中的mysql版本
shell> yum info mysql-community-server Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Installed Packages Name : mysql-community-server Arch : x86_64 Version : 5.7.27 Release : 1.el7 Size : 746 M Repo : installed From repo : mysql57-community Summary : A very fast and reliable SQL database server URL : http://www.mysql.com/ License : Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights: reserved. Under GPLv2 license as shown in the Description field. Description : The MySQL(TM) software delivers a very fast, multi-threaded,: multi-user, and robust SQL (Structured Query Language) database: server. MySQL Server is intended for mission-critical, heavy-load: production systems as well as for embedding into mass-deployed: software. MySQL is a trademark of Oracle and/or its affiliates:: The MySQL software has Dual Licensing, which means you can use the: MySQL software free of charge under the GNU General Public License: (http://www.gnu.org/licenses/). You can also purchase commercial: MySQL licenses from Oracle and/or its affiliates if you do not: wish to be bound by the terms of the GPL. See the chapter: "Licensing and Support" in the manual for further info.:: The MySQL web site (http://www.mysql.com/) provides the latest: news and information about the MySQL software. Also please see: the documentation and the manual for more information.:: This package includes the MySQL server binary as well as related: utilities to run and administer a MySQL server.
安装mysql
shell> yum install mysql-server
启动mysql
shell> systemctl start mysqld
查看mysql是否启动
shell> ps -ef | grep mysql mysql 26517 1 0 13:13 ? 00:00:00 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid root 26578 25533 0 13:13 pts/1 00:00:00 grep --color=auto mysql
或
shell> netstat -tlnp | grep mysql tcp6 0 0 :::3306 :::* LISTEN 26517/mysqld
设置root账户密码
因为mysql5.7为了安全性的考虑,在安装的时候随机生成了一个初始密码,放在/var/log/mysqld.log文件中。查询/var/log/mysqld.log文件中的初始密码。cat /var/log/mysqld.log | grep password ---------------------------------------- 2019-10-08T03:17:09.602477Z 1 [Note] A temporary password is generated for root@localhost: ,MuwPzvkf0;y
初始密码为:
,MuwPzvkf0;y
修改root密码为:root
mysql -uroot -p,MuwPzvkf0;y mysql> set password=password('root'); ---------------------------------------- Query OK, 0 rows affected, 1 warning (0.00 sec)
在重新设置密码的时候,如果密码强度不够高,会提示不安全,需要重新设置。像
root
,123456
都无法设置了。MySQL5.6.6版本之后增加了密码强度验证插件validate_password,相关参数设置的较为严格。使用了该插件会检查设置的密码是否符合当前设置的强度规则,若不满足则拒绝设置。影响的语句和函数有:create user,grant,set password,password(),old password。
测试时为了方便,确需设置简单密码时,可以参考 mysql5.7修改root密码 进行设置。
也可以参考:https://blog.csdn.net/u014236541/article/details/78244601和https://www.cnblogs.com/ivictor/p/5142809.html进入mysql
shell> mysql -uroot -proot mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.27 MySQL Community Server (GPL)Copyright (c) 2000, 2019, 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 | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec)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 -ADatabase changed mysql> show tables; +---------------------------+ | Tables_in_mysql | +---------------------------+ | columns_priv | | db | | engine_cost | | event | | func | | general_log | | gtid_executed | | help_category | | help_keyword | | help_relation | | help_topic | | innodb_index_stats | | innodb_table_stats | | ndb_binlog_index | | plugin | | proc | | procs_priv | | proxies_priv | | server_cost | | servers | | slave_master_info | | slave_relay_log_info | | slave_worker_info | | slow_log | | tables_priv | | time_zone | | time_zone_leap_second | | time_zone_name | | time_zone_transition | | time_zone_transition_type | | user | +---------------------------+ 31 rows in set (0.00 sec)mysql> quit Bye
设置mysql数据编码格式为utf8。
编辑my.cnf
shell> vi /etc/my.cnf
在my.cnf中修改内容
[mysqld] character_set_server=utf8
重启mysql后,登录mysql查看设置结果:
mysql> SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';+--------------------------+-----------------+ | Variable_name | Value | +--------------------------+-----------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | | collation_connection | utf8_general_ci | | collation_database | utf8_general_ci | | collation_server | utf8_general_ci | +--------------------------+-----------------+ 10 rows in set (0.01 sec)
执行mysql_secure_installation
安装完mysql-server后,进入生产环境之前,一定要运行一次mysql_secure_installation。运行mysql_secure_installation会执行几个设置:- 为root用户设置密码
- 删除匿名账号
- 取消root用户远程登录
- 删除test库和对test库的访问权限
- 刷新授权表使修改生效
参考:MySQL----mysql_secure_installation 安全配置向导
匿名账户参考:https://www.cnblogs.com/wzzkaifa/p/7000808.html
其它
启动mysql:systemctl start mysqld
停止mysql:systemctl stop mysqld
重启mysql:systemctl restart mysqld
查看mysql状态:systemctl status mysqld
mysql服务开启:systemctl enable mysqld
mysql服务关闭:systemctl disable mysqld
查看mysql服务是否开启:systemctl list-unit-files|grep mysqld
查看mysql版本:mysql -V
my.cnf配置文件读取顺序:mysqld --help --verbose 2> /dev/null | grep -A1 ‘Default options’
linux 利用yum源安装mysql5.7相关推荐
- Linux 利用yum源安装nginx
环境 1, CentOS 7 2, nginx 1.12.2 步骤 1,添加nginx源 rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS ...
- Linux 利用yum源安装subversion(svn)客户端
前言 CentOS 7 subversion(svn) 安装过程 yum 方式安装 shell> yum install subversion 检查是否安装成功 shell> svn -- ...
- Linux 利用yum源安装php5.6+nginx
前言 CentOS 7 nginx1.12.2 php5.6 nginx已经安装完成,且document root 目录为/usr/share/nginx/html. 步骤 1,添加php5.6源 s ...
- Linux 利用yum源安装php7.0+nginx
环境 1, CentOS 7 2, nginx1.12.2 3, php7.0 nginx已经安装完成,且document root 目录为/usr/share/nginx/html. 步骤 1,添加 ...
- Linux 通过yum源安装subversion(svn)服务端
目录 前言 通过yum源安装subversion(svn)服务端 基本的SVN服务端配操作 确定一个SVN目录 新建SVN仓库 给SVN仓库添加用户 给SVN仓库的用户授权 SVN仓库配置 启动服务器 ...
- Centos7使用yum源安装mysql5.7和redis
Centos7使用yum源安装mysql5.7 Centos7使用yum源安装redis windows安装mysql5.7 RPM是什么: RPM 是 LINUX 下的一种软件的可执行程序,你只要安 ...
- Centos 利用yum源安装 nginx stream模块
环境 CentOS 7.9 (腾讯云服务器) nginx 1.20.1 配置stream参考这里. nginx 动态模块 nginx 1.9.11 开始增加加载动态模块支持,从此不再需要替换nginx ...
- 如何用yum源安装MySQL5.7
1.检查我们的yum源,我们服务器的yum源必须要是正常的,不管是本地源还是网络源都可以. 2.检查我们的网关(再这个绝对路径,可能有些人的网卡名称不是这个 /etc/sysconfig/networ ...
- CentOS 8 利用yum源安装nginx
环境 1, CentOS 8 2, nginx 1.18.0 步骤 1,先安装 yum-utils shell> yum install yum-utils 2,添加nginx源.创建文件/et ...
最新文章
- Win10系列:JavaScript访问文件和文件夹
- angular1.0 $http jsonp callback
- Linux服务器编程之:link()函数,ln命令,symlink,readlink,案例说明
- 三维重建:QT+OpenNI+Kinect图像校正
- Robot Framework 内置变量
- java 获取远程文件_java获取远程文件
- 摄像头大数据分析跟踪均值漂移算法-spark和python
- linux使用windows中编辑的文件,格式问题
- OpenCV精进之路(八):图像轮廓和图像分割修复——轮廓查询和多边形包围轮廓
- vue 自定义键盘组件_vue 自定义 数字键盘+mint UI MessageBox的应用
- 【习题基础知识】输入与输出、简单循环(好多图贴上去好累...要看图的话我把word文档发给你)...
- js逆向巨潮mcode
- 原来苹果手机是这样清理内存的,能腾出大量内存,难怪用这么久还流畅
- video添加第一帧作为播放前图片(此方法 已失效)
- 关于西门子软件SIMIT虚拟在环调试的一些问题解决
- linux下安装php并配置运行环境
- 大数据生态(六)zookeeper集群部署(Linux和Windows[含一键启动脚本])
- python实现图书管理系统——通过excel文件或者TXT文件存放数据
- 概念模型、逻辑模型和物理模型的区别
- 解决Windows 下git官网下载很慢