centos7手动安装mysql服务_Centos7下安装mysql服务

yum install -y perl-Module-Install.noarch

yum -y install perl perl-devel

#命令下载mysql

wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz

tar -zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz

#复制解压后的mysql目录

cp -r mysql-5.6.33-linux-glibc2.5-x86_64 /usr/local/mysql

#添加用户组

groupadd mysql

#添加用户mysql 到用户组mysql

useradd -g mysql mysql

cd /usr/local/mysql/

mkdir ./data/mysql

chown -R mysql:mysql ./

./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql

cp support-files/mysql.server /etc/init.d/mysqld

chmod 755 /etc/init.d/mysqld

cp support-files/my-default.cnf /etc/my.cnf

#修改启动脚本

vi /etc/init.d/mysqld

#修改项:

basedir=/usr/local/mysql/

datadir=/usr/local/mysql/data/mysql

#删除/etc/my.cnf文件

rm -f /etc/my.cnf

#启动服务

service mysqld start

#更换密码

./bin/mysqladmin -u root -h localhost.localdomain password 'root'

#登录mysql

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

#登录之后将其他用户的密码也可改为root

update mysql.user set password=password('root') where user='root';

flush privileges;

#远程访问

GRANT ALL PRIVILEGES ON *.* to 'root'@'192.168.1.10' identified by '123456';

flush privileges;

#加入环境变量,

export PATH=$PATH:/usr/local/mysql//bin

source /etc/profile

#测试,任意目录下执行进行访问数据库服务

mysql -uroot -proot

da4108c26015fb953ed8d4ea660c8a64.png

内容来源于网络如有侵权请私信删除

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值