共计 1897 个字符,预计需要花费 5 分钟才能阅读完成。
- 下载 (速度慢时可以去清华镜像下载)
- 上传到服务器(数据库服务器一般不能连接外网,所以需要通过这种方式安装)
-
解压
-
高版本 tar
[root@localhost ~]# tar -zxvf mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz [root@localhost ~]# mv /usr/local/mysql-8.0.17-linux-glibc2.12-x86_64/ /usr/local/mysql
-
低版本 tar
[root@localhost ~]# xz -d mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz [root@localhost ~]# tar xvf mysql-8.0.17-linux-glibc2.12-x86_64.tar -C /usr/local/ [root@localhost ~]# mv /usr/local/mysql-8.0.17-linux-glibc2.12-x86_64/ /usr/local/mysql
-
-
添加用户并附加权限
[root@localhost ~]# useradd mysql [root@localhost ~]# chown -R mysql.mysql /usr/local/mysql/
-
初始化 (注意控制台输出的账户和密码 hrKXDyFs?9#N)
[root@localhost ~]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
-
配置
[root@localhost ~]# mkdir /usr/local/mysql/logs [root@localhost ~]# touch /usr/local/mysql/logs/log.err [root@localhost ~]# touch /usr/local/mysql/data/localhost.localdomain.pid [root@localhost ~]# chown -R mysql.mysql /usr/local/mysql/ [root@localhost ~]# vi /etc/my.cnf #修改 [client] socket=/usr/local/mysql/mysql.sock default-character-set = utf8mb4 [mysqld] datadir=/usr/local/mysql/data socket=/usr/local/mysql/mysql.sock symbolic-links=0 sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' max_connections=800 character-set-server=utf8mb4 collation-server=utf8mb4_general_ci default-authentication-plugin=mysql_native_password [mysqld_safe] log-error=/usr/local/mysql/logs/log.err pid-file=/usr/local/mysql/data/localhost.localdomain.pid !includedir /etc/my.cnf.d [root@localhost ~]# vi /etc/profile # 添加环境变量 export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib # 使配置生效 [root@localhost ~]# source /etc/profile
-
启动设置
[root@localhost ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql [root@localhost ~]# chkconfig --add /usr/local/mysql/support-files/mysql
-
启动
[root@localhost ~]# systemctl start mysql
-
登录
mysql -uroot -phrKXDyFs?9#N
-
修改密码后才能进行其他操作
alter user 'root'@'localhost' identified by 'wangBin_123'
正文完