linux下部署mysql8.0

一、上传安装包到Linux 

1、传路径:/usr/local/

2、解压缩
链接:https://pan.xunlei.com/s/VMzY80ky4m31C7StfrT_3-uuA1
提取码:exsd
tar xvf mysql
-8.0.17-linux-glibc2.12-x86_64.tar.xz 3、重命名 mv mysql-8.0.17-linux-glibc2.12-x86_64 mysql 二、安装配置 1、修改 vi /etc/my.cnf [client] port=3306 socket=/var/lib/mysql/mysql.sock [mysqld] port=3306 user=mysql socket=/var/lib/mysql/mysql.sock basedir=/usr/local/mysql datadir=/usr/local/mysql/data 2、创建mysql组与用户 groupadd mysql useradd -g mysql mysql 3、初始化mysql /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ 执行结果如下【root@localhost: 跟着的是初始密码。记下,后面用到 】: 2019-09-10T10:24:51.816431Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.17) initializing of server in progress as process 11400 2019-09-10T10:24:56.404516Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: )sTNHf/sp7er 2019-09-10T10:24:58.587884Z 0 [System] [MY-013170] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.17) initializing of server has completed 4、创建sock文件夹与命令链接 chown -R mysql:mysql /usr/local/mysql mkdir -p /var/lib/mysql ; chown -R mysql:mysql /var/lib/mysql ln -s /usr/local/mysql/bin/mysql /usr/bin 5、启动服务 /usr/local/mysql/support-files/mysql.server start 6、修改初始密码 mysql -uroot -p 修改密码 ,我这里的新密码是123456 ALTER USER 'root'@'localhost' IDENTIFIED BY '123456'; 绍 mysql密码忘记,需修改密码 skip-grant-tables 跳过密码登录 /etc/my.cnf update mysql.user set authentication_string=password('datang123') where user='root'; #修改密码成功 7、开启远程访问 use mysql; update user set host='%' where user='root'; flush privileges; exit; 8、关闭防火墙 systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service #禁止firewall开机启动 9、配置成服务并开机启动 cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql chkconfig mysql on chkconfig --add mysql 这样可以使用命令 service mysql start service mysql stop mysql连接方式:mysql -h 127.0.0.1 -u root -P 3306 -p

 

posted @ 2022-04-01 11:23  四毛二(ت)  阅读(219)  评论(0编辑  收藏  举报
/* 鼠标点击求赞文字特效 */