mysql5.7安装详细步骤,解决groupby语句不好使以及密码修改出错问题和一些注意事项

1.这里我将mysql安装在/usr/local/mysql目录里面,也可以安装在其他地方

mkdir /usr/local/mysql

2.下载mysql压缩包

wget http://dev.MySQL.com/get/Downloads/MySQL-5.7/mysql-5.7.11-Linux-glibc2.5-x86_64.tar.gz

也可以本地下载好再上传上去  百度mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz下载  一堆....

3.解压并复制


tar -xvf mysql-5.7.11-Linux-glibc2.5-x86_64.tar.gz
mv mysql-5.7.11-Linux-glibc2.5-x86_64/* /usr/local/mysql/

4.创建data目录
mkdir /usr/local/mysql/data


5.创建mysql用户和修改权限

useradd -g mysql mysql
groupadd mysql
chown -R mysql.mysql /usr/local/mysql/

6. 复制配置文件到 /etc/my.cnf

cp -a ./support-files/my-default.cnf /etc/my.cnf (选择y)

注意:可能会没有这个文件,可以自己创建

这个文件详细查看最后附(非常重要文件)

7.初始化数据

下载libaio组件:

[root@localhost mysql]# yum search libaio 

[root@localhost mysql]# yum install libaio 

初始化:
[root@localhost mysql]# ./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
2018-11-01T14:26:41.459474Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-11-01T14:26:44.253496Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-11-01T14:26:44.568930Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-11-01T14:26:44.791987Z 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: 2893c293-dde2-11e8-a3dc-20040fed0444.
2018-11-01T14:26:44.821425Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-11-01T14:26:44.826541Z 1 [Note] A temporary password is generated for root@localhost: Bey1x-drTfre  (这是初始密码)

8. mysql的服务脚本放到系统服务中

cp -a ./support-files/mysql.server /etc/init.d/mysqld

cp  /bin/*  /usr/bin/

9.启动服务  service mysqld start 

10.修改密码 

 mysql -u root  mysql 

注意:如果不行的话   在my.cnf文件最后加 skip-grant-tables 跳过密码进入配置,再重启mysql进入控制台

如果进入成功 密码校验

mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)

mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)
 

update mysql.user set authentication_string=PASSWORD('password') where User='root';
            flush privileges;

11.
需要远程连接需关闭防火墙 并赋予外部连接权限
开远程登录 

mysql>use mysql;

mysql>update user set host = '%' where user = 'root';

mysql>select host, user from user;  (%表示所有)

关防火墙
service iptables stop 
chkconfig iptables off 

12.进入控制台

如果加了skip-grant-tables,则注释掉,然后重启 service mysqld restart 

[root@localhost mysql]# mysql -u root -p     输入密码    进入控制台

重置密码:mysql> SET PASSWORD = PASSWORD('您得密码');
Query OK, 0 rows affected, 1 warning (0.01 sec)

13.大功告成,可以用远程客户端连接啦。

 

附:   1. 初始化或启动报错 在data文件夹下localhost.localdomain.err文件找错误原因。

        2.如果初始化失败,请检查下错误文件和my.cnf文件,然后删除data文件夹下内容。

      2. my.cnf配置:

 

[client]
#password    = your_password
port        = 3306
socket        = /usr/local/mysql/data/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port        = 3306
socket        = /usr/local/mysql/data/mysql.sock
datadir        = /usr/local/mysql/data
sql_mode        = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION 


#添加密码验证插件
plugin-load-add=validate_password.so

#服务器在启动时加载插件,并防止在服务器运行时删除插件
validate-password=FORCE_PLUS_PERMANENT

character-set-server = utf8
#skip-grant-tables

#skip-locking
max_connections=10000                       #performent
key_buffer_size = 5120M                     #performent
max_allowed_packet = 16M                    #performent
table_open_cache = 142000                   #performent
sort_buffer_size = 8M                       #performent
net_buffer_length = 64K                     #performent
read_buffer_size = 8M                       #performent
read_rnd_buffer_size =  8M                  #performent
myisam_sort_buffer_size = 8M
lower_case_table_names=1
tmp_table_size= 128M                        #performent
thread_cache_size = 64                      #performent
query_cache_size = 128M                     #performent
query_cache_type = 1                        #performent
innodb_buffer_pool_size = 36864M            #performent
#innodb_additional_mem_pool_size = 512M      #performent
join_buffer_size = 8M                       #performent
log_bin_trust_function_creators=1           #performent
slow_query_log=ON
slow_query_log_file=/usr/local/mysql/data/slowquery.log        #performent
long_query_time=1                                          #performent
log-bin=/usr/local/mysql/data/mysql-bin  #performent
binlog_format=mixed
server-id    = 1
binlog-do-db=rshshop
binlog-ignore-db=mysql


[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout


# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!

#skip-networking

# Replication Master Server (default)
# binary logging is required for replication
#log-bin=mysql-bin

# binary logging format - mixed recommended
#binlog_format=mixed

# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
#server-id    = 1
#binlog-do-db=rshshop
#binlog-ignore-db=mysql

# Replication Slave (comment out master section to use this)
#
# To configure this host as a replication slave, you can choose between
# two methods :
#
# 1) Use the CHANGE MASTER TO command (fully described in our manual) -
#    the syntax is:
#
#    CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
#    MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
#
#    where you replace <host>, <user>, <password> by quoted strings and
#    <port> by the master's port number (3306 by default).
#
#    Example:
#
#    CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
#    MASTER_USER='joe', MASTER_PASSWORD='secret';
#
# OR
#
# 2) Set the variables below. However, in case you choose this method, then
#    start replication for the first time (even unsuccessfully, for example
#    if you mistyped the password in master-password and the slave fails to
#    connect), the slave will create a master.info file, and any later
#    change in this file to the variables' values below will be ignored and
#    overridden by the content of the master.info file, unless you shutdown
#    the slave server, delete master.info and restart the slaver server.
#    For that reason, you may want to leave the lines below untouched
#    (commented) and instead use CHANGE MASTER TO (see above)
#
# required unique id between 2 and 2^32 - 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
#server-id       = 2
#
# The replication master for this slave - required
#master-host     =   <hostname>
#
# The username the slave will use for authentication when connecting
# to the master - required
#master-user     =   <username>
#
# The password the slave will authenticate with when connecting to
# the master - required
#master-password =   <password>
#
# The port the master is listening on.
# optional - defaults to 3306
#master-port     =  <port>
#
# binary logging - not required for slaves, but recommended
#log-bin=mysql-bin

# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /usr/local/mysql/var
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /usr/local/mysql/var
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
引用中的错误信息提示了一个与"sql_mode=only_full_group_by"相关的错误。这个错误是由于MySQL的版本升级到5.7后引入了新的严格模式,其中一个严格模式就是"only_full_group_by"。这个模式要求在执行GROUP BY聚合操作时,SELECT语句中的列必须要么出现在GROUP BY子句中,要么作为聚合函数的参数。如果SELECT语句中的列既不在GROUP BY子句中,也不在聚合函数中,那么会产生该错误。 引用提供了关于解决MySQL 5.7中的GROUP BY查询问题解决方法。根据该引用的描述,可以通过两种方式解决这个问题。第一种方式是将GROUP BY子句中的列都添加到SELECT语句中,以确保所有列都符合严格模式的要求。第二种方式是使用聚合函数来替代那些没有出现在GROUP BY子句中的列。 引用进一步解释了"only_full_group_by"模式的意义,即对于GROUP BY聚合操作,所有在SELECT语句中的列都必须要么出现在GROUP BY子句中,要么作为聚合函数的参数。 因此,要解决mysql5.7执行GROUP BY查询的问题,你可以通过将GROUP BY子句中的列添加到SELECT语句中或者使用聚合函数来替代那些没有出现在GROUP BY子句中的列。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [MySQL5.7版本group by错误](https://blog.csdn.net/GuangPeng_Ding/article/details/124867682)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [Mysql升级到5.7后遇到的group by查询问题解决](https://download.csdn.net/download/weixin_38596093/12826519)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值