本文摘自PHP中文网,作者藏色散人,侵删。
1、下载mysql
1 2 3 4 | #进入local目录
cd /usr/local/
#下载mysql
wget https:
|
2、解压mysql修改名称
1 2 3 | tar -zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.7.17-linux-glibc2.5-x86_64 mysql
mkdir data
|
3、添加用户和组
1 2 3 | groupadd mysql
useradd -r -s /sbin/nologin -g mysql mysql -d /usr/local/mysql
chown -R mysql.mysql /usr/local/mysql/
|
4、安装命令
1 2 3 4 | yum -y install libaio-devel
./bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
cp -a ./support-files/my- default .cnf /etc/my.cnf
cp -a ./support-files/mysql.server /etc/init.d/mysqld
|
5、修改配置文件
1 2 3 4 5 | #打开配置目录
vi /etc/my.cnf
#增加目录配置
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data
|
6、启动,修改root密码,添加远程连接用户权限
1 2 3 4 5 6 7 8 | #修改环境变量配置文件
vi /etc/profile
#增加mysql全局变量,使service mysqld start可以在任意位置使用
export PATH= $PATH :/usr/local/mysql/bin
#即时生效
source /etc/profile
#启动mysql
service mysqld start
|
1 2 3 4 5 6 7 8 9 10 | #mysql刚安装完毕没有密码进入mysql命令行
mysql -uroot -p
#查询mysql用户
select User, Host, Password FROM mysql.user;
#修改root密码
update mysql.user set password=password( 'root' ) where User= "root" ;
#为root添加远程权限
grant all privileges on *.* to 'root' @ '%' identified by 'root' with grant option;
#刷新权限
flush privileges;
|
以上就是Centos如何安装mysql5.7的详细内容,更多文章请关注木庄网络博客!
相关阅读 >>
Linux系统关机命令是什么
如何在Linux上创建,列出和删除docker容器
Linux比较文件不同的方法
Linux中postgresql和postgis的安装和使用方法
怎么查看Linux版本信息
Linux格式化硬盘命令是什么?
Linux 不能下载怎么办
Linux如何删除目录
Linux如何查看cpu信息
Linux和unix的区别
更多相关阅读请进入《Linux》频道 >>
转载请注明出处:木庄网络博客 » Centos如何安装mysql5.7