在centos7的普通用户下二进制安装mysql5.5版本
来源:互联网 发布:淘宝买翡翠是真的吗 编辑:程序博客网 时间:2024/05/21 20:26
首将mysql5.5上传到服务器上并改名为mysql,方便操作。我们要将mysql安装在我们的用户目录下,测试名路径和mysql下的目录如下:
[test1@chen mysql]$ pwd/home/test1/mysql
[test1@chen mysql]$ lsbin data include lib mysql-test scripts sql-benchCOPYING docs INSTALL-BINARY man README share support-files
我们将support下的my-small.cnf复制到mysql目录下作配置文件并命名为my.cnf。(注意:5.6版本的这个目录下的东西有些不一样,因此就要复制 my-default.cnf 。)
[test1@chen mysql]$ cp ./support-files/my-small.cnf ./my.cnf[test1@chen mysql]$ lsbin docs lib mysql-test shareCOPYING include man README sql-benchdata INSTALL-BINARY my.cnf scripts support-files
然后我们用 vi 命令编辑修改配置文件,指明客户端和服务端的一些路径并根据自己的需要更改端口,我这里把端口改为3307。(注意:5.6版本的没有 client 如果提示客户端也需要一些路径的话 ,我们给加上就可以。)如下:
# The following options will be passed to all MySQL clients[client]#password = your_passwordport = 3307socket = /home/test1/mysql/mysql.sock# Here follows entries for some specific programs# The MySQL server[mysqld]port = 3307socket = /home/test1/mysql/mysql.sockbasedir =/home/test1/mysqldatadir =/home/test1/mysql/datalog-error = /home/test1/mysql/mysql.log
接下来我们用安装 mysql 的用户对数据库进行初始化了,此时要注意初始化数据库需要依赖包,如果没有安装系统会报错,我们在普通用户下用 sudo 权限安装一下,(注意:5.6版本的就会提示少库,可以网上找一下命令。)安装代码代码如下:
[test1@chen mysql]$ sudo yum -y install libaio-devel[sudo] password for test1: Loaded plugins: fastestmirrorbase | 3.6 kB 00:00 epel | 4.3 kB 00:00 extras | 3.4 kB 00:00 updates | 3.4 kB 00:00 (1/7): epel/x86_64/group_gz | 170 kB 00:00
接下来初始化数据库(注意5.6版本可能会提示内存不足一系列的原因,我们可以改小一些内存然后在下面的语句中加上默认按自己改的 my.cnf 执行即可):
[test1@chen mysql]$ scripts/mysql_install_db --user=test1 --datadir=/home/test1/mysql/data Installing MySQL system tables...170924 18:43:16 [Note] ./bin/mysqld (mysqld 5.5.52) starting as process 10994 ...OKFilling help tables...170924 18:43:16 [Note] ./bin/mysqld (mysqld 5.5.52) starting as process 11000 ...OK
出现两个OK就代表成功了,然后我们就可以启动数据库了,启动数据文件是 bin 目录下的 mysqld ,(5.6版本的话,可能会出现一些其他的错误,我们只需要看一下错误日志分析一下就可以了。)代码如下:
[test1@chen mysql]$ ./bin/mysqld --defaults-file=./my.cnf &[1] 12445[test1@chen mysql]$ 170924 20:55:17 [Note] ./bin/mysqld (mysqld 5.5.52) starting as process 12445 ...
可以查看下进程看启动了没有,如下就是启动了:
[test1@chen mysql]$ ps -ef|grep mysqltest1 12445 12325 0 20:55 pts/0 00:00:00 ./bin/mysqld --defaults-file=./my.cnftest1 12495 12325 0 21:03 pts/0 00:00:00 grep --color=auto mysql
然后我们就可以进入数据库啦,按着 my.cnf 执行 bin 目录下的 mysql 文件,如下:
[test1@chen mysql]$ ./bin/mysql --defaults-file=./my.cnf -u root -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.5.52 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 itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>
执行一下,会让输入密码,由于我们没有设置密码,所以密码是空,直接恩 Enter 就可以进来了。如上图,提示我们已经进入数据库了。当然我们可以修改一次密码,(此方法也适用于5.6版本)在 mysql 目录下输入如下代码:
[test1@chen mysql]$ ./bin/mysqladmin --defaults-file=./my.cnf -u root password '12345678'
接着用我们的密码就可以进入数据库啦。
[test1@chen mysql]$ ./bin/mysql --defaults-file=./my.cnf -u root -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 4Server version: 5.5.52 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 itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> quitBye
如果觉得启动服务和进入数据库时输入的命令太长有些麻烦的话,我们可以创建两个脚本文件,我这里用 vi 命令分别创建两个用于启动服务和进入数据库的脚本文件start.sh和goto.sh。代码如下:
[test1@chen mysql]$ vi start.sh~~~
输入 i 进入编辑模式,然后输入:
./bin/mysqld --defaults-file=./my.cnf &
wq 保存退出后。再用 vi 创建goto.sh,并进入编辑模式输入
[test1@chen mysql]$ vi goto.sh~~~
./bin/mysql --defaults-file=./my.cnf -u root -p
保存退出,然后更改这两个文件的权限变成可执行文件就大功告成啦。
[test1@chen mysql]$ ./goto.sh Enter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 8Server version: 5.5.52 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 itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>
这是只是一种方法,这个方法缺点是只能杀进程停止服务,当然我们也可以在网上找一下方法来解决,正所谓条条大路通罗马,还有更好的方法等你去学习哦!
- 在centos7的普通用户下二进制安装mysql5.5版本
- centos7安装mysql5.5二进制分发版本
- CentOS7 在普通用户下安装rabbitmq
- CentOS7 在普通用户下安装 mysql 5.7
- centos7 二进制安装mysql5.6
- centos7 安装相应版本的mysql5.7
- MySQL5.7在CentOS7下安装
- centos7.3下二进制安装mysql5.7.19记录
- Mysql5.5的二进制安装
- mysql5.7的archive版本在win10下安装小记
- mysql5.7 版本在window下的安装
- Mysql5.7解压缩版本在windows下的安装
- centos7 二进制安装包安装 mysql5.6
- centos7 二进制安装包安装 mysql5.6.17
- VM虚拟机CentOS7下安装MySQL5.7版本遇到的一些问题
- 在windows下安装mysql5.6版本
- centos7安装mysql5.5
- CentOS7下安装MySql5.6.26
- 小木棍 [数据加强版]
- 菱形继承
- 第二周第一次课(第一章--绪论)
- C++中数组
- 算法6 抢劫
- 在centos7的普通用户下二进制安装mysql5.5版本
- 第三周项目一(3)
- 【面试的那些坑-1】用两个栈实现一个队列
- Linux系统(RedHat)在安装后的网络配置
- 坚持自己喜欢的事情
- Leetcode之Unique Paths II 问题
- LeetCode42_Trapping Rain Water
- CF 863A. Quasi-palindrome【water】
- Node之Mongodb的安装及基本操作