linux 命令行下载mysql
生活随笔
收集整理的這篇文章主要介紹了
linux 命令行下载mysql
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
[root@iz2ze4fw14evhms6nzz6t0z home]# cd /usr/local/src
[root@iz2ze4fw14evhms6nzz6t0z src]# wget -c http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz
檢查mysql組和用戶是否存在,如無創建
[root@iz2ze4fw14evhms6nzz6t0z src]# cat /etc/group | grep mysql
mysql:x:1002:
[root@iz2ze4fw14evhms6nzz6t0z src]# cat /etc/passwd | grep mysql
mysql:x:1002:1002::/home/mysql:/sbin/nologin
以上為存在的情況,如無,執行添加命令:
[root@VM_112_250_centos src]# groupadd mysql
[root@VM_112_250_centos src]# useradd -r -g mysql mysql
[root@iz2ze4fw14evhms6nzz6t0z src]# tar -xzvf mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz
創建mysql目錄
[root@iz2ze4fw14evhms6nzz6t0z src]# mkdir /usr/local/mysql
創建mysql數據目錄
[root@iz2ze4fw14evhms6nzz6t0z src]# mkdir /usr/local/mysql/data
把解壓后的所有文件移動到/usr/local/mysql目錄下
[root@VM_112_250_centos src]# mv mysql-5.7.16-linux-glibc2.5-x86_64/* /usr/local/mysql
切換到mysql目錄,然后就可以看到mysql目錄下就有了這些內容[root@VM_112_250_centos mysql]# dirCOPYING README bin data docs include lib man share support-files更改mysql目錄所屬的用戶(用戶為mysql)[root@VM_112_250_centos mysql]# chown -R mysql ../mysql/ //這里已經切到mysql目錄了,所以添加了../更改mysql目錄所屬組(組為mysql)[root@VM_112_250_centos mysql]# chgrp -R mysql ../mysql/#-R是遞歸的意思,就是把mysql目錄下的全部文件和子目錄都設置為mysql用戶和mysql組。#上面的做法是為了把mysql降權,以限定只能訪問屬于mysql用戶的文件。4. 安裝及初始化數據庫(創建系統數據庫的表)[root@VM_112_250_centos mysql]# bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/2016-11-17 13:07:49 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize2016-11-17 13:08:10 [WARNING] The bootstrap log isn't empty:2016-11-17 13:08:10 [WARNING] 2016-11-17T05:07:53.787853Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead5. 配置mysql數據庫復制配置文件[root@VM_112_250_centos mysql]# cp -a ./support-files/my-default.cnf /etc/my.cnf[root@VM_112_250_centos mysql]# cp -a ./support-files/mysql.server /etc/init.d/mysqld更改配置文件信息使用命令vim /etc/my.cnf打開my.cnf文件然后按鍵盤I按鍵進入VIM的插入模式進行編輯# These are commonly set, remove the # and set as required.basedir = /usr/local/mysqldatadir = /usr/local/mysql/dataport = 3306之后按ESC按鍵退出,:w進行保存,:q退出vim即可加入環境變量,可以參考 linux中添加環境變量的方法[root@VM_112_250_centos ~]# echo “PATH=/usr/local/mysql/bin:$PATH” >>/etc/profile設置開機啟動,可以參考 linux下配置mysql開機自啟動啟動試一下:[root@VM_112_250_centos init.d]# /etc/init.d/mysqld restartERROR! MySQL server PID file could not be found! —-因為還沒啟動所以會拋這個錯誤Starting MySQL. SUCCESS!// mysql的日志文件在/usr/local/mysql/data/foo.err文件中(foo為別名)6. 初始化密碼mysql5.7會生成一個初始化密碼,而在之前的版本首次登陸不需要密碼。[root@VM_112_250_centos bin]# ./mysql -uroot -pEnter password:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)所以這里需要初始化密碼[root@VM_112_250_centos bin]# cat /root/.mysql_secret# Password set for user 'root@localhost' at 2016-11-17 13:07:49Roa%ZwziC%yS然后進行登陸[root@VM_112_250_centos bin]# ./mysql -uroot -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 3Server version: 5.7.16Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.
總結
以上是生活随笔為你收集整理的linux 命令行下载mysql的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【项目】健康项目day5总结
- 下一篇: 在Ubuntu下编译运行C语言程序