mysql二进制安装
二进制包
https://dev.mysql.com/downloads/mysql/
把包上传到服务器上
[root@web01 tools]# ls
mysql-5.5.59-linux-glibc2.12-x86_64.tar.gz
创建用户
useradd mysql -s /sbin/nologin -M
解压缩mysql包
tar xf mysql-5.5.59-linux-glibc2.12-x86_64.tar.gz
移动到软件包目录
mv mysql-5.5.59-linux-glibc2.12-x86_64 /application/mysql-5.5.59
创建软连接
ln -s /application/mysql-5.5.59/ /application/mysql
授权
cd /application/mysql/
chown -R mysql.mysql /application/mysql/
初始化
./scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
--basedir=/application/mysql/ 初始化文件目录
--datadir=/application/mysql/data/ 数据存放的目录
--user=mysql 指定用户
二进制安装,启动mysqld_safe脚本文件默认路径都是/usr/local/路径,需要更该
sed -i 's#/usr/local#/application/mysql#g' mysqld_safe
拷贝启动文件
cp my-small.cnf /etc/my.cnf
现在就可以启动mysql了
/application/mysql/bin/mysqld_safe --user=mysql &
查看端口
lsof -i:3306
进入mysql
/application/mysql/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.59 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, 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直接可以进来
vim /etc/profile
PATH="/application/mysql/bin:$PATH"
. /etc/profile
修改启动脚本,可以使用/etc/init.d/mysql start方式启动
cd /application/mysql/support-files
sed -i 's#/usr/local#/application/mysql#g' mysql.server
cp mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
/etc/init.d/mysqld stop
修改密码
mysqladmin -uroot password 123456