• centos7 安装 mysql5.7.25


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

    [root@localhost ~]# rpm -qa|grep mariadb   // 查询出来已安装的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 mysql /usr/local/

    四、创建配置文件

    [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 /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

    八、启动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 sec)

    十一、添加远程访问权限

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

    十二、重启mysql

    [root@localhost bin]# service mysql restart
    Shutting down MySQL.. SUCCESS! 
    Starting MySQL. SUCCESS! 
  • 相关阅读:
    golang-uuid
    golang-random随机数
    git status检测不到文件变化
    vimium
    go1.11新特性,mark一下
    HTML网页滚动加载--mark一下
    docker-清理none镜像等操作
    golang websocket
    postman 快捷方式--启动图标
    tmux基本操作
  • 原文地址:https://www.cnblogs.com/yyxianren/p/10979815.html
Copyright © 2020-2023  润新知