Linux Centos7安装MySQL5.5(二进制方式安装)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux Centos7安装MySQL5.5(二进制方式安装)相关的知识,希望对你有一定的参考价值。

Linux Centos7安装mysql5.5(二进制方式安装)

一、在/app目录下下载mysql-5.5.54-linux2.6-x86_64.tar.gz`

[[email protected] /]# cd /app
[[email protected] app]# wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.54-linux2.6-x86_64.tar.gz

二、解压mysql-5.5.54-linux2.6-x86_64.tar.gz

[[email protected] app]# ta zvxf mysql-5.5.54-linux2.6-x86_64.tar.gz

三、将解压后的mysql-5.5.54-linux2.6-x86_64改名为mysql

[[email protected] app]# mv mysql-5.5.54-linux2.6-x86_64 mysql

四、添加/etc/my.cnf文件

[[email protected] app]# cd /app/mysql/support-files/
[[email protected] support-files]# cp -f my-small.cnf /etc/my.cnf

五、创建mysql目录下的data目录

[[email protected] support-files]# mkdir -p /app/mysql/data/

六、将mysql的所属用户改为mysql

[[email protected] support-files]# chown -R mysql.mysql /app/mysql/

七、增加/etc/init.d/mysqld,并为之赋予执行权限,然后初始化MySQL

[[email protected] support-files]# cp -f mysql.server /etc/init.d/mysqld
[[email protected] support-files]# chmod +x /etc/init.d/mysqld

【初始化MySQL】

[[email protected] support-files]# /app/mysql/scripts/mysql_install_db --basedir=/app/mysql --datadir=/app/mysql/data --user=mysql

八、将 /application/mysql/bin/mysqld_safe和/etc/init.d/mysqld中的/usr/local/mysql改为/app/mysq

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

九、启动mysql

[[email protected] support-files]# /etc/init.d/mysqld start
Starting MySQL.Logging to ‘/app/mysql/data/test.err‘.
.. SUCCESS! 

十、检查mysql是否启动

[[email protected] support-files]# netstat -lntup | grep mysql
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      5478/mysqld 

十一、设置环境变量

[[email protected] support-files]# echo ‘export PATH=/app/mysql/bin:$PATH‘ >>/etc/profile
[[email protected] support-files]# source /etc/profile

十二、进入mysql

[[email protected] support-files]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.54 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> 

十三、修改root密码

mysql> SET PASSWORD FOR ‘root‘@‘localhost‘ = PASSWORD(‘newpass‘);

十四、退出MySQL,使用用户名和密码再次登录MySQL

mysql> Ctrl-C -- exit!
Aborted
[[email protected] support-files]# mysql -uroot -p
Enter password: 

十五、导入sql文件(若需要执行此步骤)

mysql> source /app/cloud_note.sql
mysql> show databases;

以上是关于Linux Centos7安装MySQL5.5(二进制方式安装)的主要内容,如果未能解决你的问题,请参考以下文章

CentOS7安装MySQL5.5问题

centos7安装mysql5.5.62

CentOS7+zabbix 3.0+mysql5.5安装

CentOS7+zabbix 3.0+mysql5.5安装

MYSQL5.5源码安装 linux下

MYSQL5.5源码安装 linux下