`

centos 安装mysql

 
阅读更多

1. 下载mysql  tar.gz 

登录 https://www.mysql.com/downloads/ ,选 择相应的版本,下载

mysql-5.6.44-linux-glibc2.12-x86_64.tar.gz

2. 解压

  tar -xzvf mysql-5.6.44-linux-glibc2.12-x86_64.tar.gz

  解压后,目录结构:

Directory Contents of Directory
binscripts mysqld server, client and utility programs
data Log files, databases
docs MySQL manual in Info format
include Include (header) files
lib Libraries
mysql-test Test suite
man Unix manual pages
share Error messages, dictionary, and SQL for database installation
sql-bench Benchmarks
support-files Miscellaneous support files, including sample configuration files

 

 

3. 初始化数据库

   ./scripts/ mysql_install_db --help

 

  --basedir=path       The path to the MySQL installation directory.

  --builddir=path      If using --srcdir with out-of-directory builds, you

                       will need to set this to the location of the build

                       directory where built files reside.

  --cross-bootstrap    For internal use.  Used when building the MySQL system

                       tables on a different host than the target.

  --datadir=path       The path to the MySQL data directory.

                       If missing, the directory will be created, but its

                       parent directory must already exist and be writable.

  --defaults-extra-file=name

                       Read this file after the global files are read.

  --defaults-file=name Only read default options from the given file name.

  --force              Causes mysql_install_db to run even if DNS does not

                       work.  In that case, grant table entries that

                       normally use hostnames will use IP addresses.

  --help               Display this help and exit.                     

  --ldata=path         The path to the MySQL data directory. Same as --datadir.

  --no-defaults        Don't read default options from any option file.

  --keep-my-cnf        Don't try to create my.cnf based on template. 

                       Useful for systems with working, updated my.cnf.

                       Deprecated, will be removed in future version.

  --random-passwords   Create and set a random password for all root accounts

                       and set the "password expired" flag,

                       also remove the anonymous accounts.

  --rpm                For internal use.  This option is used by RPM files

                       during the MySQL installation process.

  --skip-name-resolve  Use IP addresses rather than hostnames when creating

                       grant table entries.  This option can be useful if

                       your DNS does not work.

  --srcdir=path        The path to the MySQL source directory.  This option

                       uses the compiled binaries and support files within the

                       source tree, useful for if you don't want to install

                       MySQL yet and just want to create the system tables.

  --user=user_name     The login username to use for running mysqld.  Files

                       and directories created by mysqld will be owned by this

                       user.  You must be root to use this option.  By default

                       mysqld runs using your current login name and files and

                       directories that it creates will be owned by you.

 

  如果此命令报错:mysql_install_db: /usr/bin/perl: bad interpreter: No such file or directory

  则需要安装perl :yum install -y perl-Module-Install.noarch

 

安装完成后,可进行初始数据库:

mysql_install_db

--basedir /home/tester/mysql/mysql-5.6.44-linux-glibc2.12-x86_64

--datadir /home/tester/mysql/data

 

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

  /home/tester/mysql/mysql-5.6.44-linux-glibc2.12-x86_64/bin/mysqladmin -u root password 'new-password'
  /home/tester/mysql/mysql-5.6.44-linux-glibc2.12-x86_64/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:

  /home/tester/mysql/mysql-5.6.44-linux-glibc2.12-x86_64/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

  cd . ; /home/tester/mysql/mysql-5.6.44-linux-glibc2.12-x86_64/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

  cd mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as /home/tester/mysql/mysql-5.6.44-linux-glibc2.12-x86_64/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

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

 

在basedir 下生成 my.cnf

修改my.conf

basedir=/home/tester/mysql/mysql-5.6.44-linux-glibc2.12-x86_64
datadir=/home/tester/mysql/data
log-error=/home/tester/mysql/log/error.log
pid-file=/home/tester/mysql/mysqld.pid
character_set_server=utf8

 

 

 

 

 

启动mysql :./mysqld_safe --defaults-file=/home/tester/mysql/mysql-5.6.44-linux-glibc2.12-x86_64/my.cnf&

 

创建用户: mysql -u root 连接mysql 服务

 命令:CREATE USER 'yanlei'@'%' IDENTIFIED BY '111111';

 命令: GRANT ALL ON *.* TO 'yanlei'@'%';

 创建数据库:create database testdb character set utf8  collate  utf8_general_ci;

 

 

停止mysql服务:./mysqladmin -u root shutdown 

 

分享到:
评论

相关推荐

    CentOS安装MySQL5.7

    ### CentOS安装MySQL 5.7知识点详解 #### 一、环境准备与系统要求 在开始安装MySQL 5.7之前,我们需要确保系统满足以下条件: - **操作系统**:CentOS 7.x或更高版本。 - **硬件配置**:至少1GB内存,推荐2GB以上;...

    CentOS安装MySQL 5.5

    ### CentOS安装MySQL 5.5知识点详解 #### 1. 概述 本文档旨在指导如何在CentOS系统上从源代码编译、安装并配置MySQL 5.5数据库管理系统。该过程涉及到软件环境的准备、编译工具的安装、MySQL源代码的编译与配置等...

    centos7.0安装mysql

    centos7.0安装mysql centos7.0安装mysql centos7.0安装mysql

    CentOS下mysql成功安装

    CentOS下MySQL成功安装 MySQL是一种流行的关系数据库管理系统,广泛应用于Web应用程序和企业级应用程序中。在CentOS操作系统中,安装MySQL服务器需要经过一系列的步骤,包括下载、编译、安装、初始化数据库、注册...

    centos安装mysql主从步骤

    根据提供的文件信息,这里将详细解释如何在 CentOS 下安装 MySQL 主从配置的步骤。以下是具体的安装过程: ### 1. 确认 CentOS 版本 确保系统版本为 CentOS 6.3,可以通过命令行输入 `cat /etc/centos-release` 来...

    Linux+安装mysql+centos+centos安装mysql

    centos 安装mysql5.7 Linux下centos安装mysql5.7 超详细步骤,带你手把手安装mysql

    CentOS 7 安装 MySQL

    CentOS 7 安装 MySQL

    Mysql 教程 - centos安装 Mysql 教程.pdf

    Mysql 教程 - CentOS 安装 Mysql 教程 本教程主要介绍了在 CentOS 平台上安装和卸载 MySQL 的步骤,涵盖了使用 yum 命令安装 MySQL 的过程,并详细解释了编辑 yum 源文件、选择 MySQL 版本、检查安装结果等步骤。 ...

    centos安装mysql5.6.docx

    CentOS 6 安装 MySQL 5.6 MySQL 是一个流行的开源关系数据库管理系统,广泛应用于 Web 应用程序中。 CentOS 6 是一个基于 Linux 的操作系统,本文将指导您如何在 CentOS 6 上安装 MySQL 5.6。 关闭 SELinux ...

    CentOS安装Mysql_Cluster集群

    #### 三、检查现有MySQL安装 - **检查命令**: 使用`rpm -qa | grep mysql`检查已安装的MySQL相关信息。 - **卸载旧版本**: 如果检测到已有安装,则需使用`yum remove mysql-server mysql-client mysql-libs`卸载。 ...

    centos 安装mysql8 亲自测试成功

    centos 安装mysql8 亲自测试成功

    Centos安装mysql数据库必须包libaio-0.3.107-10.el6.x86_64

    用于Centos操作系统,安装mysql数据时,需要的libaio文件。如果您在安装时候,报这个错误可以下载,如下: mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such ...

    centos安装mysql5.5.txt

    ### CentOS 安装 MySQL 5.5 的详细步骤与注意事项 #### 一、背景介绍 在 CentOS 系统上安装 MySQL 数据库是一项常见的任务,尤其是对于 Web 开发者和系统管理员来说。本文将详细介绍如何在 CentOS 系统上安装 ...

    centos7安装mysql5.7

    在本地虚拟机的场合,需要更换yum安装网络地址配置文件CentOS-Base.repo 从阿里云服务器下载一份CentOS-Base.repo文件存到本地

    centos安装mysql5.7.docx

    CentOS 7.6 安装 MySQL 5.7 MySQL 是一个开源的关系数据库管理系统,广泛应用于 web 开发中。下面是 CentOS 7.6 安装 MySQL 5.7 的步骤。 安装 MySQL 首先,需要新建文件夹 `/opt/mysql` 并 cd 进去。然后,下载...

    虚拟机CentOS安装mysql数据库.docx

    ### 虚拟机 CentOS 安装 MySQL 数据库及配置读写分离 #### 一、环境准备 在本文档中,我们将详细介绍如何在虚拟机 CentOS 上安装 MySQL 数据库,并进行必要的网络配置以支持读写分离的功能。为了实现这一目标,...

    2-CentOS安装MySQL1

    2-CentOS安装MySQL1

Global site tag (gtag.js) - Google Analytics