首先新建一个最小安装的LINUX centos 7 的虚拟机
systemctl stop firewalld
systemctl disable firewalld
cd /etc/sysconfig/network-scripts
ls
vi ifcfg-ens33
更改
IPADDR=本地ip
GATEWAY=网关
NETMASK=子关掩码
DNS1=8.8.8.8(公共DNS)
systemctl start network.service
/service network start
systemctl restart network.service
yum -y install vim
systemctl status network.service
systemctl stop network.service
systemctl restart network.service
ip addr
rpm -qa | grep mariadb
rpm -e --nodeps mariadb-libs-5.5.64-1.e17.x86_64
使用xftp将mysql-8.0.30-linux-glibc2.12-x86_64.tar.xz放进/opt/install中,然后解压mysql8
tar -Jxvf mysql-8.0.30-linux-glibc2.12-x86_64.tar.xz -C …/soft/
mv mysql-8.0.30-linux-glibc2.12-x86_64 mysql8
vim /etc/profile
添加完后记得应用
source /etc/profile
groupadd mysql-------创建用户组
useradd -r -g mysql mysql-------- -r:创建系统用户 -g:指定用户组
mkdir -p /opt/soft/mysql/datas
给datas权限、分组
chown -R mysql:mysql /opt/soft/mysql/datas
chmod -R 770 /opt/doft/mysql/datas
在shasha那个一步的mysql8文件夹下创建my.cnf配置文件,用于初始化MySQL数据库
配置文件参考https://blog.csdn.net/weixin_42326851/article/details/123984601
mysqld --defaults-file=/opt/soft/mysql8/my.cnf --basedir=/opt/soft/mysql8/ --datadir=/opt/soft/mysql8/datas/mysql --user=mysql --initialize-insecure
启动服务
mysqld_safe --defaults-file=/opt/soft/mysql8/my.cnf &
关闭服务
mysqladmin -uroot -proot shutdown
查看mysql是否启动
ps -ef | grep mysql
跳过密码登录mysql
mysql -uroot --skip-password
进入mysql后要改密码(改成root)
alter user’root’@‘localhost’ identified with mysql_native_password by ‘root’
展示数据库
show databases;
mysql -uroot -p
update user set user.Host=‘%’ where user.User=‘root’;