LinuxMysql5.7安装教程(亲测)Mysql5.7安装
⼀、安装前准备
前往MySQL官⽹下载对应的安装包,下载页⾯地址:
上⾯可以选择相应操作系统和版本
除此之外,也可以直接通过 Linux 服务器上下载:
content_copy
wget sql/archives/get/p/23/file/mysql-5.7.35-linux-glibc2.12-x86_
个⼈建议复制下载链接到迅雷上下载⽐较快
⼆、安装
创建mysql⽤户,会在/home下⽣成mysql⽤户⽬录
content_copy
useradd mysql
content_copy
cd /home/mysql
解压
content_copy
tar -xvf mysql-5.7.35-linux-glibc2.12-x86_
更改加压后的⽂件名
content_copy
mv mysql-5.7.35-linux-glibc2.12-x86_64 mysql57
进⼊mysql57⽬录mysql安装教程菜鸟课程
content_copy
cd /home/mysql/mysql57
创建⽬录,⽤于后⾯数据存放
content_copy
mkdir data log conf
进⼊conf创建myf,配置后以后就不使⽤/etc/myf配置
content_copy
cd /home/mysql/mysql57/conf
vim myf
content_copy
[client]
socket=/home/mysql/mysql57/mysql.sock
[mysqld]
port=3106 #端⼝⾃⼰定义
basedir=/home/mysql/mysql57
怎么打开java源码datadir=/home/mysql/mysql57/data
pid-file=/home/mysql/mysql57/mysql.piddisplay driver uninstaller
socket=/home/mysql/mysql57/mysql.sock
log_error=/home/mysql/mysql57/log/error.log
server-id=100
log_bin=/home/mysql/mysql57/binlog/mysql-bin
symbolic-links=0
init-connect='SET NAMES utf8mb4'
character-set-server=utf8mb4
lower_case_table_names=1
[mysqld_safe]
log-error=/home/mysql/mysql57/log/error.log
pid-file=/home/mysql/mysql57/mysql.pid
修改mysql57权限为mysql
content_copy
chown -R mysql:mysql /home/mysql/mysql57
初始化Mysql
content_copy
cd /home/mysql/mysql57
./bin/mysqld --defaults-file=/home/mysql/mysql57/conf/myf --initialize --user=mysql --basedir=/home/mysql/mysql57 --datadir=/home/mysql/mysql57/data
执⾏时出现
content_copy
./bin/mysqld: error while loading shared libraries: libaio.so.1:
excel最全的教程直接执⾏以下命令完后再重新初始化
content_copy
yum install -y libaio
通过以下命令查看安装⽇志
安装numpy库content_copy
tail -f /home/mysql/mysql57/log/error.log
⽇志出现
content_copy
2022-01-12T16:05:02.637084Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server op
tion (see documentation for more details).
mysqld: File '/home/mysql/mysql57/binlog/mysql-bin.index' not found (Errcode: 2 - No such file or directory)
2022-01-12T16:05:02.639335Z 0 [ERROR] Aborting
执⾏以下命令解决
content_copy
mkdir -p /home/mysql/mysql57/binlog/
touch /home/mysql/mysql57/binlog/mysql-bin.index
chown -R mysql:mysql /home/mysql/mysql57
再次查看error.log⽇⼦,出现以下⽇志则初始化成功
content_copy
tail -f /home/mysql/mysql57/log/error.log
2022-01-12T16:09:23.590301Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-01-12T16:09:24.467539Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-01-12T16:09:24.579078Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-01-12T16:09:24.646209Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 029eec3a-73c2-11ec-a7dd-00163e149163. 2022-01-12T16:09:24.647937Z 0 [Warning] Gtid table is not ready to be used. Table 'id_executed' cannot be opened.
2022-01-12T16:09:25.358771Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-01-12T16:09:25.358784Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-01-12T16:09:25.359461Z 0 [Warning] CA certificate ca.pem is self signed.
2022-01-12T16:09:25.895400Z 1 [Note] A temporary password is generated for root@localhost: Yk4F=m&ZGDk+
三、启动Mysql Server
content_copy
./bin/mysqld_safe --defaults-file=/home/mysql/mysql57/conf/myf --user=mysql &
期间提⽰(废弃)
content_copy
2022-01-13T13:52:27.555079Z mysqld_safe error: log-error set to '/var/log/mariadb/mariadb.log', however file don't exists. Create writable for user 'mysql'.
解决⽅法(废弃)
content_copy
mkdir -p /var/log/mariadb/
touch /var/log/mariadb/mariadb.log
chown -R mysql:mysql /var/log/mariadb/
期间提⽰(废弃)
content_copy
border style的属性取值
2022-01-13T13:53:46.919209Z mysqld_safe Directory '/var/lib/mysql' for UNIX socket file don't exists.
解决⽅法(废弃)
content_copy
/var/lib/mysql
chown -R mysql:mysql /var/lib/mysql
期间提⽰(废弃)
content_copy
2022-01-13T14:00:42.003092Z mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended
解决⽅法(废弃)
content_copy
mkdir /var/log/mariadbmkdir /var/run/mariadbchown
chown -R mysql:mysql /var/log/mariadbmkdir
chown -R mysql:mysql /var/run/mariadbchown
四、登录与授权
登录
content_copy
./bin/mysql --defaults-file=/home/mysql/mysql57/conf/myf -uroot -p
这⾥密码,就是安装时初始化打印在⽇志上Yk4F=m&ZGDk+
设置新密码
content_copy
alter user user() identified by "密码";
配置远程访问
content_copy
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'new_pass_word' WITH GRANT OPTION;
这⾥的%可以配置成你允许访问的IP,这⾥配置%为所有主机都可以访问
刷新配置⽣效
content_copy
FLUSH PRIVILEGES;
这⾥全部操作完成
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论