Linux centos安装mysql(解压手动安装)

系统版本:

[[email protected] ~]# uname -r

2.6.32-358.el6.i686

[[email protected] ~]# cat /etc/issue

CentOS release 6.4 (Final)

Kernel \r on an \m

下载linux generic 32bit的mysql包(http://dev.mysql.com/downloads/mysql/ )

步骤开始:

1,直接wget下载,或者下载后上传到服务器端。

2,解压。

3,将解压生成的mysql目录复制到/usr/local/mysql,并在其下新建data目录。

4,新建用户mysql和用户组mysql,并将mysql目录进行权限修改。

[[email protected] local]# pwd

/usr/local

[[email protected] local]# chown -R mysql:mysql mysql/

[[email protected] mysql]# ll

total 56

drwxr-xr-x.  2 mysql mysql  4096 Jun 26 01:42 bin

-rw-r--r--.  1 mysql mysql 17987 Jun 26 01:42 COPYING

drwxr-xr-x.  5 mysql mysql  4096 Jun 26 04:40 data

drwxr-xr-x.  2 mysql mysql  4096 Jun 26 01:42 docs

drwxr-xr-x.  3 mysql mysql  4096 Jun 26 01:42 include

drwxr-xr-x.  5 mysql mysql  4096 Jun 26 01:43 lib

drwxr-xr-x.  4 mysql mysql  4096 Jun 26 01:42 man

-rw-r--r--.  1 mysql mysql  2478 Jun 26 01:39 README

drwxr-xr-x. 28 mysql mysql  4096 Jun 26 01:42 share

drwxr-xr-x.  2 mysql mysql  4096 Jun 26 01:43 support-files

[[email protected] mysql]#

[[email protected] mysql]# pwd

/usr/local/mysql

5,初始化数据。

[[email protected] mysql]# ./bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/

[[email protected] mysql]#

6,复制配制文件。

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

[[email protected] mysql]#

7,将Mysql的服务脚本放到/etc/init.d/目录下。

[[email protected] mysql]# cp -a ./support-files/mysql.server /etc/init.d/mysqld

[[email protected] mysql]#

8,启动服务。

[[email protected] mysql]# service mysqld restart

Shutting down MySQL.. SUCCESS!

Starting MySQL.. SUCCESS!

[[email protected] mysql]#

9,查看初始密码,并登录mysql。

[[email protected] mysql]# cat /root/.mysql_secret

# Password set for user ‘[email protected]‘ at 2016-06-26 02:48:47

:jiDfmi%5kaK

[[email protected] mysql]# ./bin/mysql -uroot -p

Enter password: (此处输入上述密码)

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.7.13

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>

mysql> status    (下面会有报错,提示需要修改密码后再执行命令)

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

mysql>

10,修改mysql登录密码。

[[email protected] mysql]# ./bin/mysqladmin -uroot -p password

Enter password: (输入上述老密码)

New password:

Confirm new password:

Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

[[email protected] mysql]#

11,使用新密码即可登录mysql。

[[email protected] mysql]# ./bin/mysql -uroot -p

Enter password: (新密码)

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 8

Server version: 5.7.13 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> select version();

+-----------+

| version() |

+-----------+

| 5.7.13    |

+-----------+

1 row in set (0.01 sec)

mysql>

12,至此mysql安装完成。



报错解决:

1,

[[email protected] mysql-5.7.13]# ./bin/mysql_install_db --user=mysql

2016-06-26 02:47:09 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize

2016-06-26 02:47:09 [ERROR]   The data directory needs to be specified.

解决:需要新建data目录,指定安装目录(在非默认目录时需要指定,默认路径:/usr/local/mysql,同时需要指定./support-files/mysql.server中的basedir和datadir为相应路径)。

[[email protected] mysql-5.7.13]# ./bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql-5.7.13/ --datadir=/usr/local/mysql-5.7.13/data/

2016-06-26 02:48:47 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize

2016-06-26 02:49:19 [WARNING] The bootstrap log isn‘t empty:

2016-06-26 02:49:19 [WARNING] 2016-06-26T09:48:50.798592Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead

2016-06-26T09:48:50.898732Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)

2016-06-26T09:48:50.898778Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)

以上报错均因未在mysql.server中指定自定义的路径。

2,启动mysql服务不成功。

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

/etc/init.d/mysqld: line 256: my_print_defaults: command not found

Starting MySQL ERROR! Couldn‘t find MySQL server (/usr/local/mysql/bin/mysqld_safe)

解决:原来默认路径是/usr/local/mysql目录,这里存放目录是/usr/local/mysql-5.7.13。

将mysql-5.7.13改为mysql再启动,发现如下错误:

ERROR! MySQL server PID file could not be found!

确认当前目录所有者为root,改为mysql:

[[email protected] local]# chown -R mysql:mysql mysql/

[[email protected] local]# /etc/init.d/mysqld restart

ERROR! MySQL server PID file could not be found!

Starting MySQL....... SUCCESS!

3,登录不成功,是因为服务没启动。

[[email protected] mysql-5.7.13]# cat /root/.mysql_secret

# Password set for user ‘[email protected]‘ at 2016-06-26 02:48:47

:jiDfmi%5kaK

[[email protected] mysql-5.7.13]# ./bin/mysql -uroot -p

Enter password:

ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘ (2)

解决:上面第2个问题解决后,此问题消失(需要将mysqld服务启动)。



参考:http://www.cnblogs.com/azhw/p/5143232.html

时间: 2024-08-05 14:46:43

Linux centos安装mysql(解压手动安装)的相关文章

win10 安装 mysql解压版安装步骤

参考资料:win 10 安装 mysql 5.7 网址:http://blog.sina.com.cn/s/blog_5f39af320102wbk0.html 本文参考上面的网址的教程,感谢作者分享. 我安装的是解压版,因为安装版并没有64位的,并且安装版也就是自动安装,节省了一部分配置操作, 反正是学习,就自己动手安装解压版64位. 下面我再把步骤说明一下: 1.下载,到MySQL官网:http://dev.mysql.com/ 点击Downloads=>Community=>MySQL

mysql5.7 Installing MySQL on Microsoft Windows Using a noinstall Zip Archive(mysql解压版安装)

注:参考官网文档 mysql解压版安装配置大致分为以下6步: Extract the main archive to the desired install directory Optional: also extract the debug-test archive if you plan to execute the MySQL benchmark and test suite Create an option file Choose a MySQL server type Initiali

MySQL解压版安装配置详解

MySQL解压版安装起来比较简单,步骤相对较少.下面我们就来详细介绍一下如何在windows操作系统上安装解压班的MySQL. 1.下载解压版MySQL,地址:http://downloads.mysql.com/archives/community/ 2.解压到本地某个目录,例如我解压到了 E:\mySoftWare\mysql 目录下 截图是我修改过的 跟刚刚解压之后的会有所不同,先不用在意. 3.配置环境变量: 右键我的电脑->属性->更改设置->高级->环境变量->系

【Linux】MySQL解压版安装及允许远程访问

安装环境/工具 1.Linux( centOS 版) 2.mysql-5.6.31-linux-glibc2.5-x86_64.tar 安装步骤 1.下载mysql解压版(mysql-5.6.31-linux-glibc2.5-x86_64.tar),下载地址http://dev.mysql.com/downloads/mysql/: 2.解压mysql安装文件 命令:tar -zxvf mysql-5.6.31-linux-glibc2.5-x86_64.tar.gz 3.复制解压后的mysq

IT忍者神龟之Windows下MySQL解压版安装与配置

1. 到官网下载MySQL解压版,然后将mysql解压到任意路径,本例放在:D:\Program Files\mysql-advanced-5.6.14-win32 2. 设置环境变量,在系统变量Path中添加:;D:\Program Files\mysql-advanced-5.6.14-win32\bin 3. 在根目录下面有以"my-"开头的ini文件,随意复制一个放在根目录,如:my-default.ini,将文件名修改为my.ini,添加以下内容: [mysqld] #设置字

windows下MySQL解压版安装

MySQL的安装 一.前期准备 获取MySQL解压版安装包(本文使用的是 [mysql-5.7.28-winx64.zip]版本) 获取方式: 通过官网下载,官方下载地址:“https://dev.mysql.com/downloads/mysql/”  .(注意:需要oracle账号登录后方可下载) 通过第三方下载 二.安装 安装路径随个人喜好,本文将MySQL安装在D盘下. 将文件解压到D盘下,解压后的文件名为文件默认命名 “mysql-5.7.28-winx64”(可根据个人喜好随意命名)

MYSQL5.6.X 非在线安装版(解压版)安装过程

一.卸载以前旧版本(本人5.5版本) 1.关闭MySQL服务 以管理员身份运行cmd,执行以下命令: net stop mysql 或者右键我的电脑,在管理--服务--停止MySQL 2.卸载MySQL应用 mysqld -remove [服务名]服务名称可以在右键我的电脑,在管理--服务--右键点击MySQL查看属性找到:如下图 3.删除MySQL文件下面的将本地MySQL文件删除掉,路径可通过上图服务名称下面的可执行文件的路径查到. 4.删除注册表信息 开始->运行-> regedit 看

免安装版MySQL(解压版)安装详细教程及注意事项

1.net stop mysql 2.sc delete mysql 3.环境变量设置mysql/bin 4. set password for [email protected] = password('123'); flush privileges; 5.mysqld –-initialize 如果没有生成data文件夹,则输入下面代码: mysqld --initialize-insecure --user=mysql 6.my.ini [mysql]# 设置mysql客户端默认字符集de

window mysql 解压版安装

================================安装版本=======================================mysql安装版本需要用到如下两个软件:提示:.net 4 FrameWork相关的,先安装-->net4_框架.rar提示:microsoft visual c++ 2010 32相关的,安装vcredist2010_x86.rar ================================绿色版本=====================