MySQL安装-解压包安装

创建用户组和用户

[[email protected] software]# groupadd mysql
groupadd:“mysql”组已存在
[[email protected] software]# useradd -g mysql mysql
useradd:用户“mysql”已存在
[[email protected] software]#
[[email protected] software]# passwd mysql
更改用户 mysql 的密码 。
新的 密码:
无效的密码: 密码是一个回文
重新输入新的 密码:

解压安装包

[[email protected] software]# tar -zxvf mysql-5.7.26-el7-x86_64.tar.gz

移动解压后的文件夹

[[email protected] software]# mv mysql-5.7.26-el7-x86_64/ /usr/local/mysql

更改所属的组和用户

[[email protected] mysql]# cd /home/mysql/
[[email protected]lhost mysql]# chown -R mysql mysql/
[[email protected] mysql]# chgrp -R mysql mysql/
[[email protected] mysql]# mkdir data
[[email protected] mysql]# chown -R mysql:mysql data

安装

[[email protected] mysql]# cd /usr/local/mysql/
[[email protected] mysql]# bin/mysql_install_db --user=mysql --datadir=/home/mysql/data/
2019-07-19 11:02:18 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2019-07-19 11:02:20 [WARNING] The bootstrap log isn‘t empty:
2019-07-19 11:02:20 [WARNING] 2019-07-19T03:02:18.443343Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
2019-07-19T03:02:18.443888Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2019-07-19T03:02:18.443892Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)

设置目录及权限

[[email protected] mysql]# cp ./support-files/mysql.server /etc/init.d/mysql
[[email protected] etc]# vi my.cnf
修改配置文件
[[email protected] etc]# chown 777 my.cnf
[[email protected] etc]# chmod +x /etc/init.d/mysql 

设置开机启动

[[email protected] etc]# chkconfig --level 35 mysql on
[[email protected] etc]# chkconfig --list mysql
mysql              0:关    1:关    2:开    3:开    4:开    5:开    6:关
[[email protected] etc]# 

修改配置文件

[[email protected] /]# vi /etc/profile
修改/etc/profile,在最后添加如下内容
# 修改/etc/profile文件
#set mysql environment
export PATH=$PATH:/usr/local/mysql/bin
#使文件生效
[[email protected] /]# source /etc/profile
[[email protected] /]# 

获得mysql初始密码

[[email protected] /]# cat /root/.mysql_secret
# Password set for user ‘[email protected]‘ at 2019-07-19 11:02:18
Pkz:zkdpy50q
[[email protected] /]# 

修改密码

[[email protected] /]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.26-log

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

mysql> set PASSWORD = PASSWORD(‘root‘);
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> exit
Bye

添加远程访问权限

[[email protected] /]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.26-log MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set host=‘%‘ where user=‘root‘;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select host,user from user;
+-----------+---------------+
| host      | user          |
+-----------+---------------+
| %         | root          |
| localhost | mysql.session |
| localhost | mysql.sys     |
+-----------+---------------+
3 rows in set (0.00 sec)

mysql> 

重启mysql生效

[[email protected] /]# service mysql stop
Shutting down MySQL.. SUCCESS!
[[email protected] /]# service mysql start
Starting MySQL... SUCCESS!
[[email protected] /]# service mysql status
 SUCCESS! MySQL running (46983)
[[email protected] /]# 

打开端口

firewall-cmd --permanent --zone=public --add-port=3306/tcp //永久
[[email protected] /]# firewall-cmd --permanent --zone=public --add-port=3306/tcp
success
[[email protected] /]# firewall-cmd --reload
success
[[email protected] /]# 

原文地址:https://www.cnblogs.com/song-wentao/p/11291433.html

时间: 2024-10-31 20:27:10

MySQL安装-解压包安装的相关文章

Redis安装-解压包安装

下载地址:http://redis.io/download 1.将下载好的redis复制到:/opt/software/redis-4.0.9.tar.gz 2.在/opt/software/目录下执行命令:tar -zxvf redis-4.0.9.tar.gz -C /opt/local/ 3.进入/opt/local/redis-4.0.9/目录:cd /opt/local/redis-4.0.9 4.执行make install命令: 以上步骤可以将redis安装完成. 将redis设置

Tomcat 7.0 64位免安装解压版 安装及配置

Tomcat 7.0 win7 64位免安装解压版 安装及配置 Tomcat 推荐官方下载,地址如下 http://tomcat.apache.org/download-70.cgi 或者可在我的CSDN论坛下载,地址为: http://download.csdn.net/detail/shangguanyunlan/9273785 我下载的是apache-tomcat-7.0.65 最新的已经到8了,自己选择合适的版本即可. 下载解压到任意盘符,自己决定,我是下载到D盘的. 环境变量配置:Ja

Linux centos安装mysql(解压手动安装)

系统版本: [[email protected] ~]# uname -r 2.6.32-358.el6.i686 [[email protected] ~]# cat /etc/issue CentOS release 6.4 (Final) Kernel \r on an \m 下载linux generic 32bit的mysql包(http://dev.mysql.com/downloads/mysql/ ). 步骤开始: 1,直接wget下载,或者下载后上传到服务器端. 2,解压. 3

mysql_windows解压包安装

WIN下安装64位的解压版mysql-5.6.24-winx64 参考如下安装步骤: 1.将解压缩后的文件放到自己想要的地方 并配置环境变量. 示例中存放的目录为:D:\Program Files\mysql-5.6.24-winx64 2.在环境变量中添加:MYSQL_HOME:F:\mysql\mysql-5.6.14-winx64,在path路径中加入:%MYSQL_HOME%\bin.配置环境变量不是必须的,只是为了能更方便的在命令行中使用mysql的命令行工具. ###########

解压包安装sql

1.下载压缩包,地址1(官网下载):https://www.mysql.com/downloads/   地址2(百度网盘):https://pan.baidu.com/s/1uBhx5pu8APLfGu_cjnW2rg 提取码: qhsp 官网下载方法如下: 2.解压压缩包到自己喜欢的文件夹中:(以我为例是D:\newdream\mysql\mysqlserver,后文以安装路径代替) 3.设置环境变量,右键我的电脑 ->属性 ->高级系统设置 ->环境变量 ->在系统变量中找到

MySQL zip解压版安装过程及问题

1.首先解压mysql压缩包,然后添加环境变量path(D:\mysql-5.7.11\bin) 2.修改D:\mysql-5.7.11\my-default.ini? 文件的配置项 ?       # basedir = D:\mysql-5.7.11 # datadir = D:\mysql-5.7.11\data # port = 3306 3.cmd管理员开启,进入D:\mysql-5.7.11\bin 执行mysqld -install? ? ?问题: 启动时 net start my

MySQL服务解压版安装

1.环境变量配置 右键计算机–属性–高级系统设置–环境变量,在系统变量中找到Path编辑,在结尾处追加你的mysql的bin文件夹地址D:\Program Files\mysql-8.0.12-winx64\bin2.创建my.ini文件[client] # pipe= socket=MYSQL port=3306 [mysql]no-beep # default-character-set= # SERVER SECTION# ---------------------------------

mysql系列-解压版安装mysql和配置以及密码修改

1.环境变量设置. MYSQL_HOME D:\MySQL\mysql-5.6.23-winx64 然后在path中配置 %MYSQL_HOME%\bin; 2.my.ini 配置 basedir = D:\MySQL\mysql-5.6.23-winx64 datadir = D:\MySQL\mysql-5.6.23-winx64\data port = 3306 character-set-server = utf8 sql_mode=NO_ENGINE_SUBSTITUTION,STRI

安装解压版Mysql方法

1.下载解压版的Mysql,并解压到安装目录下 2.复制解压包中my-default.ini文件并改名为my.ini.修改my.ini相关参数 3.配置环境变量 4.在CMD中安装Mysql服务. 在这里需要注意一定要进入解压包的bin目录下进行安装操作.否则运行Mysql服务路径会出错(如果出错了,使用sc delete mysql操作来删除服务,然后重新安装:有时删除不彻底,还去了注册表把Mysql注册信息删除了) 5.启动服务 6.进入MySQL,初始密码为空 7.修改MySQL密码