下载解压mysql8
https://downloads.mysql.com/archives/community/
我的服务器是64位的,所以选择红框中的版本
![](https://img.haomeiwen.com/i5460809/426b660ac067e60a.png)
导入远程服务器上
![](https://img.haomeiwen.com/i5460809/9ecb664eefddd0ad.png)
解压到/usr/local/mysql
tar -xf mysql-8.0.23-linux-glibc2.12-x86_64.tar.xz -C /usr/local/mysql
配置环境变量
vim /etc/profile
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:MYSQL_HOME/bin
生效配置文件
source /etc/profile
初始化mysql
记住root默认的密码
mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
![](https://img.haomeiwen.com/i5460809/f43b6a591d1f8e9c.png)
启动mysql
[root@VM-16-14-centos support-files]# ./mysql.server start
Starting MySQL.. SUCCESS!
登录修改默认密码
mysql -u root -p 密码
##修改密码
alter user 'root'@'localhost' identified by '123456';
注意
Starting MySQL... ERROR The server quit without updating PID file (/usr/local/mysql/localhost.local
解决方案:
chmod 777 /etc/my.cnf
my_print_defaults: [Warning] World-writable config file ‘/usr/local/mysql/my.cnf‘ is ignored.
解决方案:
设置/etc/my.cnf的权限,chmod 664 /etc/my.cnf
外部无法连接mysql服务器 is not allowed to connect to this MySQL server
解决方案:
mysql服务器安装成功后,只能本机localhost访问,可以开放任意的ip访问。
![](https://img.haomeiwen.com/i5460809/e73ceac853d4f721.png)
mysql> update user set host = '%' where user ='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> select host from user where user='root';
+------+
| host |
+------+
| % |
+------+
1 row in set (0.00 sec)
网友评论