CentOS离线安装MySQL

上传文件

scp mysql-* root@192.168.0.111:/root/

解压

tar -zxvf mysql-5.7-*.tar.gz
mv mysql-5.7-* /usr/local/mysql
cd /usr/local/mysql

创建用户和用户组

groupadd mysql
useradd -g mysql mysql 
passwd  mysql
chown -R mysql:mysql /usr/local/mysql 

执行安装脚本

cd /usr/local/mysql
./scripts/mysql_install_db --user=mysql

启动

启动

cd /usr/local/mysql
./support-files/mysql.server start

若已启动mysql,则kill掉

ps aux|grep mysql
# kill -9 上边的进程号 
# 或者下边一条命令即可杀掉所有MySQL进程 
ps aux|grep mysql|awk '{print $2}'|xargs kill -9

更改mysql密码

cd /usr/local/mysql
./bin/mysqladmin -u root -h localhost.localdomain password 'root'

登录

./bin/mysql -h127.0.0.1 -uroot -proot

授权root远程登录权限

grant all privileges on *.* to root@'%' identified by 'root';
 flush privileges;

将MySQL加入Service系统服务

cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on service
service mysqld restart
service mysqld status

配置my.cnf

vim my.cnf
# 添加以下两条语句并保存退出 
character_set_server=utf8
lower_case_table_names=1
max_allowed_packet=100M

重启mysql

systemctl status mysqld

问题:

[root@node2 ~]# mysql
-bash: mysql: command not found

/usr/local/bin目录下缺失mysql执行脚本导致,需要建立软链接:

ln -s /usr/local/mysql/bin/mysql /usr/bin
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值