下載解壓mysql8
https://downloads.mysql.com/archives/community/
我的服務(wù)器是64位的丽柿,所以選擇紅框中的版本
image.png
導(dǎo)入遠(yuǎn)程服務(wù)器上
解壓到/usr/local/mysql
tar -xf mysql-8.0.23-linux-glibc2.12-x86_64.tar.xz -C /usr/local/mysql
配置環(huán)境變量
vim /etc/profile
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:MYSQL_HOME/bin
生效配置文件
source /etc/profile
初始化mysql
記住root默認(rèn)的密碼
mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
啟動(dòng)mysql
[root@VM-16-14-centos support-files]# ./mysql.server start
Starting MySQL.. SUCCESS!
登錄修改默認(rèn)密碼
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.
解決方案:
設(shè)置/etc/my.cnf的權(quán)限鲸鹦,chmod 664 /etc/my.cnf
外部無(wú)法連接mysql服務(wù)器 is not allowed to connect to this MySQL server
解決方案:
mysql服務(wù)器安裝成功后昆咽,只能本機(jī)localhost訪問(wèn),可以開放任意的ip訪問(wèn)壶唤。
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)