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.初始化數據

下載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

7. 複製配置文件到 /etc/my.cnf

cp -a ./support-files/my-default.cnf /etc/my.cnf (選擇y)

注意:可能會沒有這個文件,可以自己創建

這個文件詳細查看最後附(非常重要文件)

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管理臺 執行

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配置:

 

[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 

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

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章