Liunx安装mysql8.0
1.在自己要安装的目录文件夹中,下载mysql(本机是/usr/local)下
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz
2.解压mysql
tar xvJf mysql-8.0.21-linux-glibc2.12-x86_64.tar.xz(下载的包名)
3.重命名文件夹
mv mysql-8.0.21-linux-glibc2.12-x86_64 mysql-8.0
4.在mysql-8.0目录下,创建data文件夹 存储文件
mkdir data
groupadd mysql
useradd -g mysql mysql
6.授权用户
chown -R mysql.mysql /usr/local/mysql-8.0
7.进入mysql-8.0,切换到bin目录下
cd bin
8.初始化基础信息
./mysqld --user=mysql --basedir=/usr/local/mysql-8.0 --datadir=/usr/local/mysql-8.0/data/ --initialize
-------------初始化时会得到临时密码--------------------记住临时密码,第一次进入mysql时用
9.编辑my.cnf文件
vi /etc/my.cnf
[mysqld]
basedir = /usr/local/mysql-8.0
datadir = /usr/local/mysql-8.0/data
socket = /usr/local/mysql-8.0/mysql.sock
character_set_server=utf8
port = 3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[client]
socket = /usr/local/mysql-8.0/mysql.sock
default-character-set=utf8
10.回到mysql.0目录,添加mysqld服务到系统
cp -a ./support-files/mysql.server /etc/init.d/mysql
11.授权以及添加服务(设置开机自启)
chmod +x /etc/init.d/mysql
chkconfig --add mysql
12.启动mysql
service mysql start
13.将mysql命令添加到服务
ln -s /usr/local/mysql-8.0/bin/mysql /usr/bin
14.登录mysql mysql -u root -p 密码使用之前随机生成的密码
15.修改root密码 其中root是新的密码自己设置
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
16.执行,使密码生效
flush privileges;
17.选择数据库,改为远程可以连接
use mysql;
update user set host='%' where user='root';
flush privileges;
18.测试连接
---------------------------------------
redis启动
进入redis安装目录 (启用自配置文件)
./redis-server /usr/local/redis/etc/redis.conf
--------------------------------------
nginx启动(root用户下)
进入nginx安装目录下的sbin
./nginx
重启 ./nginx -s reload
实测好用---------------------------------=_=