内网linux 安装mysql

mysql下载地址

正文:
之前的其他笔记步骤有问题
把安装包传到linux虚拟机
1、在 /usr/local/ 目录下新建 mysql文件夹,
2、解压 mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz ,把mysql-5.7.22-linux-glibc2.12-x86_64 里的东西复制到 /usr/local/mysql下
3、在/usr/local/mysql 下可以先新建 data文件夹

4、更改mysql目录下所有的目录及文件夹所属的用户组和用户,以及权限
useradd mysql
chown -R mysql:mysql /usr/local/mysql
chmod -R 755 /usr/local/mysql
5、编译安装并初始化mysql,务必记住初始化输出日志末尾的密码
(备注:数据库管理员临时密码,没有的话,可以试试先到my.cnf 下设置跳过密码检查)
如 ymAixGz5mm(I

cd /usr/local/mysql/bin
./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql
6、到/etc 下找到 my.cnf ,下面这个覆盖进去(注意 datadir 的路径要对) ,
注意 第二行 user = root 一定得加

[mysqld]
user  = root
datadir=/usr/local/mysql/data
port = 3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
#socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
max_connections=400
innodb_file_per_table=1
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

# include all files from the config directory
#!includedir /etc/my.cnf.d

(知识点: #表名大小写不明感,敏感为 lower_case_table_names=1)
7、然后:启动mysql服务器 /usr/local/mysql/support-files/mysql.server start
如果有下面问题时,可以先重启虚拟机试试,如果不行,参考第6步
在这里插入图片描述
再不行,就参考这个:PID问题
其内容为:
Starting MySQL. ERROR! The server quit without updating PID file (/usr/local/mysql/var/localhost.localdomain.pid).

  1. 99%权限问题
    我的安装在 /usr/local
    cd /usr/local
    数据库目录 chown -R mysql:mysql mysql
    在这里插入图片描述

8、添加软连接,并重启mysql服务 (这里建立了两个 /etc/init.d/mysql /usr/bin/mysql )
ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
service mysql restart
9、登录mysql,修改密码(密码为步骤5生成的临时密码)
mysql -u root -p
Enter password:
mysql>set password for root@localhost = password(‘123456’);

10、开放远程连接
mysql>use mysql;
msyql>update user set user.Host=’%’ where user.User=‘root’;
mysql>flush privileges;

11、设置开机自动启动 , 将服务文件拷贝到init.d下,并重命名为mysql
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
12、赋予可执行权限
chmod +x /etc/init.d/mysqld
13、添加服务
chkconfig --add mysqld
14、显示服务列表
chkconfig --list
15、结束

相关资料https://blog.csdn.net/sinat_24393863/article/details/93506102?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-3.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-3.control

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值