- 官网下载社区版,.tar.xz文件(传送)
- 卸载MariaDB,centos7中使用yum install,默认安装的是此数据库,此数据库完全兼容mysql。
ps -ef | grep maria*, ps -ef | grep mysql, yum remove xxx
- tar解压tar.xz文件到你喜欢的目录
tar -xvf mysql-8.0.19-linux-glibc2.12-x86_64.tar.xz
- 自己在/etc目录下新建my.cnf,例如:
# MySQL 配置文件,
# 数据库目录 /home/local/mysql-8.0.19-linux-glibc2.12-x86_64/data
[client]
port=33689
# mysql socket 文件存放地址
socket=/tmp/mysql.sock
# 默认字符集
default-character-set=utf8
[mysqld]
server-id=1
# 端口
port=33689
# 运行用户
user=mysql
# 最大连接
max_connections=200
socket=/tmp/mysql.sock
# mysql 安装目录(解压后文件的目录)
basedir=/home/local/mysql-8.0.19-linux-glibc2.12-x86_64
# 数据目录(这里放在我们新建的 /data/mysql 下)
datadir=/home/local/mysql-8.0.19-linux-glibc2.12-x86_64/data
pid-file=/home/local/mysql-8.0.19-linux-glibc2.12-x86_64/data/mysql.pid
init-connect='SET NAMES utf8'
character-set-server=utf8
# 数据库引擎
default-storage-engine=INNODB
log_error=/home/local/mysql-8.0.19-linux-glibc2.12-x86_64/data/mysql-error.log
slow_query_log_file=/home/local/mysql-8.0.19-linux-glibc2.12-x86_64/data/mysql-slow.log
transaction_isolation=READ-COMMITTED
default-authentication-plugin=mysql_native_password
# 跳过验证密码
#skip-grant-tables
[mysqldump]
quick
#max_allowed_packet=16M
EOF
- 添加linux添加mysql用户并授权目录访问权限
groupadd mysql
useradd -g mysql mysql
chown -R mysql:mysql chown -R /home/local/mysql-8.0.19-linux-glibc2.12-x86_64/data
chown -R mysql:mysql /home/local/mysql-8.0.19-linux-glibc2.12-x86_64/data
chown -R mysql:mysql /home/local/mysql-8.0.19-linux-glibc2.12-x86_64
chown -R 755 /home/local/mysql-8.0.19-linux-glibc2.12-x86_64
chown -R 755 /home/local/mysql-8.0.19-linux-glibc2.12-x86_64/data/
- 初始化mysql数据库,期间可能需要你安装对应的依赖库
yum install libaio*
./bin/mysqld --initialize --user=mysql
- 找到默认的root密码并修改
# 先启动
/support-files/mysql.server start
vi /home/local/mysql-8.0.19-linux-glibc2.12-x86_64/datadata/mysql-error.log
image.png
./bin/mysql -uroot -p
CREATE USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
./support-files/mysql.server stop
./support-files/mysql.server start
- mysql8默认caching_sha2_password设置是另一个问题
https://dev.mysql.com/doc/refman/8.0/en/caching-sha2-pluggable-authentication.html
网友评论