安装MySQL5.7与MySQL8.0,先按照一下方法安装MySQL8.0步骤
1、下载MySQL8.0:https://dev.mysql.com/downloads/mysql/
2、点击下拉选择 Linux – Generic,找到名为 mysql-8.0.30-linux-glibc2.12-x86_64.tar.xz 点击下载即可
3、解压xz文件为tar文件,注意命令无过程显示需要等待窗口跳至下一行
xz -d /usr/local/mysql-8.0.30-linux-glibc2.12-x86_64.tar.xz
tar -xvf /usr/local/mysql-8.0.30-linux-glibc2.12-x86_64.tar
4、mysql-8.0.30-linux-glibc2.12-x86_64文件夹重命名为:mysql80,然后赋予权限 chown -R mysql.mysql /usr/local/mysql80
5、修改配置文件 vi /usr/local/mysql80/my.cnf
[client]
port=3307
# mysql57 不要这个
mysqlx_port=33070
socket=/tmp/mysql80.sock
# mysql57 不要这个
mysqlx_socket=/tmp/mysqlx80.sock
[mysqld]
# skip-grant-tables
# mysql安装目录
basedir=/usr/local/mysql80
# mysql数据库目录
datadir=/usr/local/mysql80/data
port=3307
innodb_file_per_table=1
character-set-server=utf8
# mysql57 不要这个
mysqlx_port=33070
socket = /tmp/mysql80.sock
# mysql57 不要这个
mysqlx_socket=/tmp/mysqlx80.sock
[mysqld_safe]
# 错误日志
log-error=/usr/local/mysql80/data/error.log
# pid文件
pid-file=/usr/local/mysql80/data/mysqld.pid
tmpdir=/tmp/mysql80
6、赋予配置文件权限 chmod 755 /usr/local/mysql80/my.cnf
7、修改连接服务文件 vi /usr/local/mysql80/support-files/mysql.server
# 这两项在开头比较好找
basedir=/usr/local/mysql80
datadir=/usr/local/mysql80/data
# 这项默认的不用找
lockdir=’/var/lock/subsys’
# 这项默认有但是需要在最后改个80
lock_file_path=”$lockdir/mysql80″
# 下面两个藏在下面细心的找一下
mysqld_pid_file_path=/usr/local/mysql80/data/mysqld.pid
conf=/usr/local/mysql80/my.cnf
8、复制注册连接服务文件
cp -i /usr/local/mysql80/support-files/mysql.server /etc/init.d/mysql80
9、初始化mysql80
/usr/local/mysql80/bin/mysqld –defaults-file=/usr/local/mysql80/my.cnf –user=mysql –initialize
root@localhost: 初始密码
10、启动MySQL80服务 service mysql80 start 然后要记得开放防火墙的3307端口才能使用外部连接
11、登录 /usr/local/mysql80/bin/mysql –socket=/tmp/mysql80.sock -u root -p’初始密码’
12、重置密码,登录后依次执行命令
ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘你的密码’;
flush privileges;(权限重新加载命令)
13设计开机启动
vi /usr/lib/systemd/system/mysql80.service
[Unit]
Description=MySQL 8.0.30 Database Server
Documentation=https://www.mysql.com
After=syslog.target
After=network.target
[Service]
Type=forking
User=mysql
Group=mysql
ExecStart=/etc/init.d/mysql80 start
ExecReload=/etc/init.d/mysql80 restart
ExecStop=/etc/init.d/mysql80 stop
TimeoutSec=300
PrivateTmp=true
[Install]
WantedBy=multi-user.target
systemctl start mysql80 启动
systemctl status mysql80 启动状态
systemctl enable mysql80 开机启动
14、安装MySQL57过程一样,my.cnf上文有说明,哪些是不需要的,还有重要的一点事,安装MySQL57上面所有步骤里面含有80的,换成57即可
评论0