Linux centos7下安装 MySQL 8.1X 解压版安
1https://dev.mysql.com/downloads/mysql/
![](https://img.haomeiwen.com/i7018485/37d2b013565ead7e.png)
![](https://img.haomeiwen.com/i7018485/bf7d65ba1a8c24d9.png)
![](https://img.haomeiwen.com/i7018485/1110545241a827b5.png)
下载之前 先安装 wget:yum -y install wget
下载mysql8.0: wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.18-el7-x86_64.tar.gz
![](https://img.haomeiwen.com/i7018485/6ee58e3084c375cb.png)
解压mysql安装包: tar -zxvf mysql-8.0.18-el7-x86_64.tar.gz
![](https://img.haomeiwen.com/i7018485/0919daa432d13cd0.png)
重新命名mysql:mv mysql-8.0.18-el7-x86_64 mysql
![](https://img.haomeiwen.com/i7018485/fa4d5d23e9c87580.png)
![](https://img.haomeiwen.com/i7018485/4fb5e9c8cc200e6e.png)
![](https://img.haomeiwen.com/i7018485/04eece20c66fbaea.png)
[mysqld]
socket=/usr/local/mysql/mysql.sock
port=3306
user=mysql
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
max_allowed_packet=128M
[mysqld_safe]
log-error=/usr/local/mysql/mariadb/mariadb.log
pid-file=/usr/local/mysql/run/mariadb/mariadb.pid
[client]
port=3306
socket=/usr/local/mysql/mysql.sock
!includedir /etc/my.cnf.d
![](https://img.haomeiwen.com/i7018485/61d05d539e225edb.png)
初始化mysql :/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
复制启动文件到系统启动路径下:cp support-files/mysql. server /etc/rc.d/init.d/mysql
![](https://img.haomeiwen.com/i7018485/53d1428ef917d43d.png)
![](https://img.haomeiwen.com/i7018485/0a05a4669647a9f9.png)
启动命令:service mysqld start
重新启动命令:systemctl restart mysqld.service
启动命令:systemctl start mysqld.service
停止启动命令:systemctl stop mysqld.service
终极启动命令:/etc/init.d/mysql start
![](https://img.haomeiwen.com/i7018485/91bd647b59574093.png)
原因是没有下载服务
/usr/local/mysql/bin/mysql -u root -p密码
![](https://img.haomeiwen.com/i7018485/2dc8f11e2af3df18.png)
因为mysql命令的路径在/usr/local/mysql/bin下面,所以你直接使用mysql命令时,ln -s /usr/local/mysql/bin/mysql /usr/bin
系统在/usr/bin下面查此命令,所以找不到了
解决办法是: ln -s /usr/local/mysql/bin/mysql /usr/bin 做个链接即可
![](https://img.haomeiwen.com/i7018485/0382eba3b768d114.png)
修改密码:alter user 'root'@'localhost' identified by 'demwlxx@Mysql227';
![](https://img.haomeiwen.com/i7018485/c38b1624cd732255.png)
修改远程连接操作:update mysql.user set host='%' where user='root';
注意一定要重新刷新让你的修改器作用:flush privileges;
![](https://img.haomeiwen.com/i7018485/ae6a38b6ad278a06.png)
特别声明:仅学习使用,请勿用于商业用途,如拿去非法使用与本人无关!
这里所有操作技术来源网络,如有侵权,请联系删除!