linux安装mysql8.0详解


1.下载官方打包好的二进制安装包:
#wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz

2.解压文件:
[root@yum ~]tar -xJvf mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz -C /usr/local/
[root@yum ~] mv /usr/local/mysql-8.0.12-linux-glibc2.12-x86_64/ /usr/local/mysql
 
3.配置参数文件:
[root@yum ~] cat /etc/my.cnf
[mysqld]
server-id                      = 1
port                           = 3306
mysqlx_port                    = 33060
mysqlx_socket                  = /tmp/mysqlx.sock
datadir                        = /data/mysql
socket                         = /tmp/mysql.sock
pid-file                       = /tmp/mysqld.pid
log-error                      = error.log
slow-query-log                 = 1
slow-query-log-file            = slow.log
long_query_time                = 0.2
log-bin                        = bin.log
relay-log                      = relay.log
binlog_format                 =ROW
relay_log_recovery            = 1
character-set-client-handshake = FALSE
character-set-server           = utf8mb4
collation-server               = utf8mb4_unicode_ci
init_connect                   ='SET NAMES utf8mb4'
innodb_buffer_pool_size        = 1G
join_buffer_size               = 128M
sort_buffer_size               = 2M
read_rnd_buffer_size           = 2M
log_timestamps                 = SYSTEM
lower_case_table_names         = 1
default-authentication-plugin  =mysql_native_password
 
4.创建目录授权等:
[root@yum ~]# groupadd mysql
[root@yum ~]# useradd mysql
useradd: group mysql exists - if you want to add this user to that group, use -g.
[root@yum ~]# mkdir -p /data/mysql
[root@yum ~]#  chown -R mysql:mysql /data/mysql/
chown: invalid user: ‘mysql:mysql’
[root@yum ~]# useradd mysql
useradd: group mysql exists - if you want to add this user to that group, use -g.

[root@yum ~]# chown -R mysql:mysql /data/mysql/
chown: invalid user: ‘mysql:mysql’
[root@yum ~]# groupadd mysql
groupadd: group 'mysql' already exists
[root@yum ~]# useradd mysql
useradd: group mysql exists - if you want to add this user to that group, use -g.
[root@yum ~]# chmod -R 775 /data/mysql/
[root@yum ~]# /usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql --initialize-insecure/usr/local/mysql/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
[root@yum ~]# yum search libaio
Loaded plugins: fastestmirror
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Determining fastest mirrors
============================================================== N/S matched: libaio ==============================================================
libaio.i686 : Linux-native asynchronous I/O access library
libaio.x86_64 : Linux-native asynchronous I/O access library
libaio-devel.i686 : Development files for Linux-native asynchronous I/O access
libaio-devel.x86_64 : Development files for Linux-native asynchronous I/O access

  Name and summary matches only, use "search all" for everything.
[root@yum ~]# yum install libaio
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base                                                                                                                      | 3.6 kB  00:00:00     
epel                                                                                                                      | 5.3 kB  00:00:00     
extras                                                                                                                    | 3.4 kB  00:00:00     
updates                                                                                                                   | 3.4 kB  00:00:00     
(1/4): extras/7/x86_64/primary_db                                                                                         | 205 kB  00:00:00     
(2/4): epel/x86_64/updateinfo                                                                                             | 989 kB  00:00:00     
(3/4): epel/x86_64/primary_db                                                                                             | 6.8 MB  00:00:00     
(4/4): updates/7/x86_64/primary_db                                                                                        | 6.5 MB  00:00:00     
Resolving Dependencies
--> Running transaction check
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================
 Package                          Arch                             Version                                  Repository                      Size
=================================================================================================================================================
Installing:
 libaio                           x86_64                           0.3.109-13.el7                           base                            24 k

Transaction Summary
=================================================================================================================================================
Install  1 Package

Total download size: 24 k
Installed size: 38 k
Is this ok [y/d/N]: y
Downloading packages:
libaio-0.3.109-13.el7.x86_64.rpm                                                                                          |  24 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libaio-0.3.109-13.el7.x86_64                                                                                                  1/1 
  Verifying  : libaio-0.3.109-13.el7.x86_64                                                                                                  1/1 

Installed:
  libaio.x86_64 0:0.3.109-13.el7                                                                                                                 

Complete!
[root@yum ~]# /usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql --initialize-insecure2019-07-15T11:43:48.070950+08:00 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.16) initializing of server in progress as process 5934
2019-07-15T11:43:48.073173+08:00 0 [ERROR] [MY-010124] [Server] Fatal error: Can't change to run as user 'mysql' ;  Please check that the user exists!
2019-07-15T11:43:48.073182+08:00 0 [ERROR] [MY-013236] [Server] Newly created data directory /data/mysql/ is unusable. You can safely remove it.
2019-07-15T11:43:48.073229+08:00 0 [ERROR] [MY-010119] [Server] Aborting
2019-07-15T11:43:48.073505+08:00 0 [System] [MY-010910] [Server] /usr/local/mysql/bin/mysqld: Shutdown complete (mysqld 8.0.16)  MySQL Community Server - GPL.
[root@yum ~]# chown -R mysql:mysql /var/lib/mysql
chown: invalid user: ‘mysql:mysql’
//安装mysql,添加用户组时:
[root@yum ~]# useradd mysql
useradd: group mysql exists - if you want to add this user to that group, use -g.
[root@yum ~]# groups mysql
groups: mysql: no such user
//解决措施:
[root@yum ~]# useradd -r -g mysql mysql
[root@yum ~]# chown -R mysql:mysql /var/lib/mysql
chown: cannot access ‘/var/lib/mysql’: No such file or directory
[root@yum ~]#  chown -R mysql:mysql /data/mysql
[root@yum ~]# [root@yum ~]# yum install libaio
-bash: [root@yum: command not found
[root@yum ~]# /usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql --initialize-insecure[root@yum ~]# cat /data/mysql/error.log | grep -i password
2019-07-15T11:59:41.517488+08:00 5 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
[root@yum ~]# cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysql
//--启动数据库:
[root@yum ~]# /etc/init.d/mysql start
Starting MySQL.2019-07-15T04:00:40.560358Z mysqld_safe error: log-error set to '/var/log/mariadb/mariadb.log', however file don't exists. Create writable for user 'mysql'.
The server quit without updating PID file (/tmp/mysqld.pid)[FAILED]
[root@yum ~]# vim /etc/my.cnf
///解决措施:
[root@yum ~]# mkdir /var/log/mariadb
[root@yum ~]# touch /var/log/mariadb/mariadb.log
[root@yum ~]# chown -R mysql:mysql  /var/log/mariadb/
[root@yum ~]# 
//启动成功
[root@yum ~]# /etc/init.d/mysql start
Starting MySQL..                                           [  OK  ]
//停止成功
[root@yum ~]# /etc/init.d/mysql stop
Shutting down MySQL...                                     [  OK  ]
//重启成功
[root@yum ~]# /etc/init.d/mysql restart
Shutting down MySQL..                                      [  OK  ]
Starting MySQL..                                           [  OK  ]

你可能感兴趣的:(linux安装mysql8.0详解)