linux之MySQL安装部署

MySQL安装配置步骤:

1.    进入/home/oldboy/tools 执行上传mysql数据库指令并创建一个mysql用户

#rz -y上传压缩包

[[email protected] tools]# cd /home/oldboy/tools/

[[email protected] tools]# useradd -s /sbin/nologin  -M mysql

[[email protected] tools]# ls

mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz

2.    解压mysql安装包

[[email protected] tools]# tar xf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz

[[email protected] tools]# ls

mysql-5.6.35-linux-glibc2.5-x86_64        mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz

3.    移动解压出来的mysql目录到指定目录

#没有这个目录则创建       mkdir -p /application

[[email protected] tools]# mv mysql-5.6.35-linux-glibc2.5-x86_64 /application/mysql-5.6.35

[[email protected] tools]# ls /application/

mysql-5.6.35

4.    给mysql创建一个软链接

[[email protected] tools]# ln -s /application/mysql-5.6.35 /application/mysql

[[email protected] tools]# ll /application/

total 8

lrwxrwxrwx  1 root root   25 Mar  8 23:41 mysql -> /application/mysql-5.6.35

drwxr-xr-x 13 root root 4096 Mar  8 23:38 mysql-5.6.35

5.    赋予mysql安装目录中mysql软件的所属者
[[email protected] application]# chown -R mysql.mysql /application/mysql/

[[email protected] application]# ll mysql/

total 68

drwxr-xr-x  2 mysql mysql  4096 Mar  8 23:38 bin

-rw-r--r--  1 mysql mysql 17987 Nov 28 21:36 COPYING

drwxr-xr-x  3 mysql mysql  4096 Mar  8 23:38 data

drwxr-xr-x  2 mysql mysql  4096 Mar  8 23:38 docs

drwxr-xr-x  3 mysql mysql  4096 Mar  8 23:38 include

drwxr-xr-x  3 mysql mysql  4096 Mar  8 23:38 lib

drwxr-xr-x  4 mysql mysql  4096 Mar  8 23:38 man

drwxr-xr-x 10 mysql mysql  4096 Mar  8 23:38 mysql-test

-rw-r--r--  1 mysql mysql  2496 Nov 28 21:36 README

drwxr-xr-x  2 mysql mysql  4096 Mar  8 23:38 scripts

drwxr-xr-x 28 mysql mysql  4096 Mar  8 23:38 share

drwxr-xr-x  4 mysql mysql  4096 Mar  8 23:38 sql-bench

drwxr-xr-x  2 mysql mysql  4096 Mar  8 23:38 support-files

6.    初始化数据库
[[email protected] application]# /application/mysql/scripts/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data --user=mysql

Installing MySQL system tables...2017-03-08 23:50:31 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
…………
WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server

7.    复制mysql安装目录下的脚本去linux系统服务并给执行权限
[[email protected] application]# cp /application/mysql/support-files/mysql.server  /etc/init.d/mysqld

[[email protected] application]# chmod +x /etc/init.d/mysqld

[[email protected] application]# ll /etc/init.d/mysqld

-rwxr-xr-x 1 root root 10875 Mar  8 23:51 /etc/init.d/mysqld

8.    替换配置文件

[[email protected] application]# sed -i ‘s#/usr/local/mysql#/application/mysql#g‘ /application/mysql/bin/mysqld_safe /etc/init.d/mysqld

9.    覆盖原来的配置文件

[[email protected] application]# \cp /application/mysql/support-files/my-default.cnf /etc/my.cnf

10.  启动mysql服务

[[email protected] application]# /etc/init.d/mysqld start

Starting MySQL.Logging to ‘/application/mysql/data/localhost.err‘.
 SUCCESS!

[[email protected] application]# lsof -i:3306          #MySQL默认端口3306
COMMAND  PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
mysqld  5189 mysql   10u  IPv6  30071      0t0  TCP *:mysql (LISTEN)

11.  PATH路径和开机自启动

[[email protected] application]# echo ‘export PATH=/application/mysql/bin:$PATH‘ >>/etc/profile

[[email protected] application]# source /etc/profile

[[email protected] application]# which mysql

/application/mysql/bin/mysql

[[email protected] application]#    chkconfig --add mysqld

[[email protected] application]#    chkconfig mysqld on

[[email protected] application]# chkconfig --list|grep mysqld
mysqld             0:off    1:off    2:on    3:on    4:on    5:on    6:off

12.  给MySQL root用户设置密码
[[email protected] application]# /application/mysql/bin/mysqladmin -u root password ‘oldboy123‘
Warning: Using a password on the command line interface can be insecure.         #这个只是一个警告,原因是在命令行输入密码!

测试是否能登陆

[[email protected] application]# mysql -uroot -poldboy123

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 2
Server version: 5.6.35 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, 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> quit
Bye

到这一步mysql数据库就安装成功了!MySQL常用命令如下   ↓

MySQL简单常用命令

1.    查看所有数据库:show databases;

2.    创建一个数据库:create database oldboy;

3.    删除一个数据库(危险):drop database oldboy;

4.    select user,host from mysql.user;

查询选择:select

user,host字段(列)

mysql数据库的user表格

5.   退出MySQL:quit

6.   给用户授权:grant all on wordpress.* to [email protected]‘172.16.1.%‘ identified by ‘123456‘

时间: 2024-07-30 09:09:49

linux之MySQL安装部署的相关文章

Linux下mysql的部署和安装-RPM方式

RPM方式安装MySQL5.6 a. 检查MySQL及相关RPM包,是否安装,如果有安装,则移除(rpm –e 名称) [[email protected] ~]# rpm -qa | grep -i mysql mysql-libs-5.1.66-2.el6_3.x86_64 [[email protected] ~]# yum -y remove mysql-libs* b. 下载Linux对应的RPM包,如:CentOS6.4_64对应的RPM包,如下: [[email protected

Linux下Opengrok安装部署与使用

Opengrok 用于管理多项目的代码非常方便.本文以Opengrok 0.12.1来讲解在RedHat Enterprise Linux上的部署 http://opengrok.github.io/OpenGrok/ 软件依赖准备: 1 JAVA                          http://www.oracle.com/technetwork/java// 2. Tomcat                    http://tomcat.apache.org/ 3.Ex

Linux下mysql安装

Linux下mysql安装,推荐使用这一种. 当然也可以在配置环境变量那文件中配置 附: mysql安装 - 创建mysql组 - useradd mysql - 创建mysql用户,并放入到mysql组中 - useradd -g mysql mysql - 进入到mysql文件夹 - 初始化数据库 - scripts/mysql_install_db ‐user=mysql - 修改文件的所有者 - chown ‐R root . - 修改date文件夹的所有者 - chown ‐R mys

Linux下MySQL安装和配置

--Linux下MySQL安装和配置 ---------------------------2014/05/18 Linux下MySQL的配置和安装 本文的安装采用 rpm 包安装 1.首先在官网下载 http://dev.mysql.com/downloads/mysql/ MySQL-client-5.6.17-1.el6.i686.rpm MySQL-server-5.6.17-1.el6.i686.rpm 2.由于RedHat中自带了mysql-libs-5.1 会和 MySQL-ser

linux下MySQL安装登录及操作

linux下MySQL安装登录及操作 二.安装Mysql 1.下载MySQL的安装文件 安装MySQL需要下面两个文件: MySQL-server-4.0.16-0.i386.rpm MySQL-client-4.0.16-0.i386.rpm 下载地址为:http://www.mysql.com/downloads/mysql-4.0.html, 打开此网页,下拉网页找到“Linux x86 RPM downloads”项,找到“Server”和“Client programs”项,下载需要的

【转】linux平台Redis安装部署

Redis是一种高级key-value数据库.它跟memcached类似,不过数据可以持久化,而且支持的数据类型很丰富.有字符串,链表,集 合和有序集合.支持在服务器端计算集合的并,交和补集(difference)等,还支持多种排序功能.所以Redis也可以被看成是一个数据结构服务 器. Redis的所有数据都是保存在内存中,然后不定期的通过异步方式保存到磁盘上(这称为“半持久化模式”):也可以把每一次数据变化都写入到一个append only file(aof)里面(这称为“全持久化模式”).

Linux环境下安装部署AWStats日志分析系统实例

AWStats是使用Perl语言开发的一款开放性日志分析系统,可分析Apache网站服务器的访问日志,还可以用来分析Samba.Vsftpd.IIS等日志信息.       此文章主要讲解如何在linux系统下安装部署关于对Apache网站服务站日志分析的AWStats. 实验步骤一,安装部署AWStats分析软件. 一,安装AWStats软件包. 直接将其解压到/usr/local/awstats目录下即可完成安装. 使用命令:mkdir -p /usr/local/awstats tar z

Linux服务器MySQL安装

Linux服务器MySQL安装 1. MySQL官网下载如图: 2. 安装MySQL [[email protected] /]# rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch 过滤MySQL: [[email protected] /]#yum repolist all |grep mysql enabled是已经开启的,现在安装mysql57-community,把disabled设置为en

Linux环境下安装部署MySQL数据库系统实例

      MySQL是一个真正的多线程,多用户的SQL数据库服务,现由Oracle公司负责运营和维护. 一,准备工作. 1,为了避免发生端口冲突.程序冲突的现象,建议查询MySQL软件安装情况,确认没有使用rpm方式安装的mysql-server.mysql软件包,否则建议将其卸载. 使用命令: rpm -q mysql-server mysql                 //查询有无mysql安装软件和服务 rpm -e mysql  --nodeps