MySQL 安装

MySQL 安装

使用华为云,xshell,xftp,navicat
1,使用xftp 把mysql拷贝到指定目录下

[root@hecs-x-medium-2-linux-20200629201536 ~]# cd /usr/local
[root@hecs-x-medium-2-linux-20200629201536 local]# ls
bin  etc  games  hostguard  include  lib  lib64  libexec  mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz  sbin  share  src  uniagent

2,安装插件

[root@hecs-x-medium-2-linux-20200629201536 local]# yum install -y libaio

3,解压

[root@hecs-x-medium-2-linux-20200629201536 local]# tar -zxvf mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz

4,具体安装

[root@hecs-x-medium-2-linux-20200629201536 local]# groupadd mysql
[root@hecs-x-medium-2-linux-20200629201536 mysql-5.7.9-linux-glibc2.5-x86_64]# useradd -r -g mysql mysql
[root@hecs-x-medium-2-linux-20200629201536 mysql-5.7.9-linux-glibc2.5-x86_64]# cd /usr/local
[root@hecs-x-medium-2-linux-20200629201536 local]# ln -s /usr/local/mysql-5.7.9-linux-glibc2.5-x86_64 mysql
[root@hecs-x-medium-2-linux-20200629201536 local]# cd mysql
[root@hecs-x-medium-2-linux-20200629201536 mysql]# mkdir mysql-files
[root@hecs-x-medium-2-linux-20200629201536 mysql]# chmod 770 mysql-files
[root@hecs-x-medium-2-linux-20200629201536 mysql]# chown -R mysql .
[root@hecs-x-medium-2-linux-20200629201536 mysql]# chgrp -R mysql .[root@hecs-x-medium-2-linux-20200629201536 mysql]# bin/mysqld --initialize --user=mysql
[root@hecs-x-medium-2-linux-20200629201536 mysql]# bin/mysql_ssl_rsa_setup
[root@hecs-x-medium-2-linux-20200629201536 mysql]# chown -R root .
[root@hecs-x-medium-2-linux-20200629201536 mysql]# chown -R mysql data mysql-files

如果出现
chown: cannot access ‘data’: No such file or directory

[root@hecs-x-medium-2-linux-20200629201536 mysql]# mkdir data
[root@hecs-x-medium-2-linux-20200629201536 mysql]# chown -R mysql data mysql-files
[root@hecs-x-medium-2-linux-20200629201536 mysql]# bin/mysqld_safe --user=mysql &

如果出现

touch: cannot touch ‘/var/log/mariadb/mariadb.log’: No such file or directory
chmod: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory
touch: cannot touch ‘/var/log/mariadb/mariadb.log’: No such file or directory
chown: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory
200629 21:24:52 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
bin/mysqld_safe: line 130: /var/log/mariadb/mariadb.log: No such file or directory
bin/mysqld_safe: line 164: /var/log/mariadb/mariadb.log: No such file or directory
touch: cannot touch ‘/var/log/mariadb/mariadb.log’: No such file or directory
chown: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory
chmod: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory
[root@hecs-x-medium-2-linux-20200629201536 mysql]# cd /etc
[root@hecs-x-medium-2-linux-20200629201536 etc]# mv my.cnf my.cnfback
[root@hecs-x-medium-2-linux-20200629201536 etc]# cd /usr/local/mysql
[root@hecs-x-medium-2-linux-20200629201536 mysql]# bin/mysqld --initialize --user=mysql
2020-06-29T13:43:25.533381Z 1 [Note] A temporary password is generated for root@localhost: ,jCFO37kVuy4

这里这个密码一定要记下来 ,jCFO37kVuy4

[root@hecs-x-medium-2-linux-20200629201536 mysql]# bin/mysql_ssl_rsa_setup
[root@hecs-x-medium-2-linux-20200629201536 mysql]# chown -R root .
[root@hecs-x-medium-2-linux-20200629201536 mysql]# chown -R mysql data mysql-files
[root@hecs-x-medium-2-linux-20200629201536 mysql]# bin/mysqld_safe --user=mysql &

运行下面代码检查是否安装成功

[root@hecs-x-medium-2-linux-20200629201536 mysql]# ps -ef | grep mysqld

附加项

[root@hecs-x-medium-2-linux-20200629201536 mysql]# cp support-files/mysql.server /etc/init.d/mysql.server

开机启动

[root@hecs-x-medium-2-linux-20200629201536 mysql]# chkconfig mysql.server on

环境变量

[root@hecs-x-medium-2-linux-20200629201536 mysql]# vi /etc/profile

最后一行加上
export PATH=/usr/local/mysql/bin:$PATH

进入mysql

[root@hecs-x-medium-2-linux-20200629201536 mysql]# mysql -uroot -p',jCFO37kVuy4'

重置密码

mysql> set passwork = 'root1234%';

设置权限

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root1234%' WITH GRANT OPTION;

刷新权限

mysql> flush privileges;

最后使用navicat 链接mysql 就可以了

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值