首页 > 数据库 >centos7 安装 mysql5.7.25

centos7 安装 mysql5.7.25

时间:2022-09-28 22:42:01浏览次数:60  
标签:25 06 local mysql5.7 centos7 usr mysql root localhost

一、检查是否安装了mysql和mariadb,若已经安装就需要卸载。

[root@localhost ~]# rpm -qa|grep   // 查询出来已安装的mariadb
[root@localhost ~]# rpm -e --nodeps 文件名   // 卸载mariadb,文件名为上述命令查询出来的文件
[root@localhost ~]# rm /etc/my.cnf      //删除配置文件

 

二、添加mysql用户及用户组

[root@localhost ~]# groupadd mysql    //创建mysql用户组
[root@localhost ~]# useradd -g mysql mysql //创建mysql用户,并添加到mysql用户组

 

三、解压文件,并移动到指定的目录下

[root@localhost ~]# tar -zvxf mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
[root@localhost ~]# mv 解压出来的文件夹名 mysql
[root@localhost ~]# mv

 

四、创建配置文件

[root@localhost support-files]# vim /etc/my.cnf
#通过vim编辑器编辑my.cnf代码如下:

[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
socket = /tmp/mysql.sock
character-set-server=utf8

log-error = /usr/local/mysql/data/mysqld.log
pid-file = /usr/local/mysql/data/mysqld.pid

 

五、初始化数据库

[root@localhost ~]# cd /usr/local/mysql/bin/
[root@localhost bin]# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/

 

六、查看初始默认密码

[root@localhost bin]# cat /usr/local/mysql/data/mysqld.log       
2019-06-05T07:08:28.263392Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-06-05T07:08:28.263457Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2019-06-05T07:08:28.263462Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2019-06-05T07:08:28.961752Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-06-05T07:08:29.039265Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-06-05T07:08:29.095290Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: b858de41-8760-11e9-84f3-00505681edfc.
2019-06-05T07:08:29.096413Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-06-05T07:08:29.096953Z 1 [Note] A temporary password is generated for root@localhost: kXJh+_RMu52K

 

七、将启动脚本放到开机初始化目录

[root@localhost ~]# cp

 

八、启动mysql

[root@localhost ~]# service mysql start
Starting MySQL. SUCCESS!

 

九、使用root账号和默认密码登录mysql

[root@localhost ~]# cd /usr/local/mysql/bin/
[root@localhost bin]# ./mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.25

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>

 

十、修改root密码

mysql> set password=password('root');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> grant all privileges on *.* to root@'%' identified by '1234567890';
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00

 

十一、添加远程访问权限

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '1234567890' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00

 

十二、重启mysql

[root@localhost bin]# service mysql restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!

 



标签:25,06,local,mysql5.7,centos7,usr,mysql,root,localhost
From: https://blog.51cto.com/u_472169/5721091

相关文章

  • gym 102586 G. matrix inversions
    考虑一个对子对\(A,B\)的贡献,如果\(x_1\ley_1,x_2\ley_2\)的一对点会贡献\(0,0\)或\(+1,+1\),\(x_1<x_2,y_1>y_2\)会贡献\(0,+1\)或\(+1,0\)。设第一种对子最......
  • centos7 中iptables、firewalld 和 netfilter 的关系
    centos7系统使用firewalld服务替代了iptables服务,但是依然可以使用iptables来管理内核的netfilter但其实iptables服务和firewalld服务都不是真正的防火墙,只是用来定......
  • Dockerfile centos7_php5.6.36
    Dockerfile:FROMcentos:7MAINTAINERwww.ctnrs.comRUNyuminstallepel-release-y&&\yuminstall-ygccgcc-c++makegd-devellibxml2-devel\libcurl-deve......
  • CentOS7下安装Mysql
    准备工作 下载地址:https://dev.mysql.com/downloads/mysql/5.7.html#downloads     Linux可能内嵌了mariaDB,这里需要将mariaDB删除:yum listinstalled|......
  • CentOS7.9 搭建DHCP服务器 - DHCP中继代理
    一、DHCP概述1.DHCP的简介DHCP(DynamicHostConfigurationProtocol),动态主机配置协议,是一个应用层协议。当我们将客户主机ip地址设置为动态获取方式时,DHCP服务器就......
  • ABC254E Small d and k(BFS)
    E-Smalldandk题目描述:  给\(n\)个顶点\(m\)条边的无向图,每个顶点的度不超过\(3\),给你\(Q\)次询问,每次询问给你一个顶点\(x\)和一个\(k\),表示求距离顶点\(x\)的长......
  • 2022 ICPC 网络预选赛(9.25)
    真容易颓。E构造一个序列\(a_1\)已经确定使得\((a_i,a_{i-1})=1,a_i>1\)求整个序列最大值。容易知道\(a_2\)是与\(a_1\)互质的最小质数若是2接下填3,2,3,2,3即可.若......
  • 25. NumPy和Matplotlib绘图
    1.前言Matplotlib是Python的绘图库,它经常与NumPy一起使用,从而提供一种能够代替Matlab的方案。不仅如此Matplotlib还可以与PyQt和wxPython等图形工具包一起......
  • 25 bootstrap--v3--datetimepicker时间选择器--应用
    在模板中引用响应的文件比如:layout.html<linkrel="stylesheet"href="{%static'stark/plugins/datetimepicker/css/bootstrap-datetimepicker.css'%}"/><scripts......
  • CentOS7.9编译安装gp
    前提条件yumupdate-yyum-yinstallepel-releaseyum–yinstallpython-pipyuminstall-ylrzsz设置python国内下载源mkdir-p~/.pipvi~/.pip/pip.conf......