CentOS7 二進位制安裝MySQL5 6 42

2022-07-21 19:15:18 字數 4077 閱讀 1261

1.  檢查是否有mariadb和mysql,如果有則解除安裝掉

3. 解壓到/usr/local中改名,並建立軟鏈結

# tar xf mysql-5.6.42-linux-glibc2.12-x86_64.tar.gz  -c /usr/local/# mv /usr/local/mysql-5.6.42-linux-glibc2.12-x86_64 /usr/local/mysql-5.6.42# ln -s /usr/local/mysql-5.6.42/ /usr/local/mysql

# ll /usr/local/total

4drwxr-xr-x. 2 root root 6 apr 11

2018

bin drwxr-xr-x. 2 root root 6 apr 11

2018

etc drwxr-xr-x. 2 root root 6 apr 11

2018

games

drwxr-xr-x. 2 root root 6 apr 11

2018

include

drwxr-xr-x. 2 root root 6 apr 11

2018

lib drwxr-xr-x. 2 root root 6 apr 11

2018

lib64

drwxr-xr-x. 2 root root 6 apr 11

2018

libexec

lrwxrwxrwx

1 root root 24 nov 29

19:40 mysql -> /usr/local/mysql-5.6.42/drwxr-xr-x 13 root root 4096 nov 29

19:39 mysql-5.6.42

drwxr-xr-x. 2 root root 6 apr 11

2018

sbin

drwxr-xr-x. 5 root root 46 apr 11

2018

share

drwxr-xr-x. 2 root root 6 apr 11

2018 src

4. 建立使用者組和使用者名稱

# groupadd mysql

# useradd -g mysql mysql -s /sbin/nologin

5. 修改配置檔案

# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

# mkdir /var/lib/mysql/

# chown -r mysql.mysql /var/lib/mysql

# cat /etc/my.cnf

[mysql]

default-character-set=utf8

[mysqld]

skip-name-resolve

port = 3306

server_id = 1

log_bin = mysql-bin

socket=/var/lib/mysql/mysql.sock

basedir=/usr/local/mysql

datadir=/usr/local/mysql/data

max_connections=200

character-set-server=utf8

default-storage-engine=innodb

lower_case_table_name=1

max_allowed_packet=16m

sql_mode=no_engine_substitution,strict_trans_tables

[client]

socket = /var/lib/mysql/mysql.sock

6. 進入mysql目錄初始化資料

# chown mysql.mysql -r /usr/local/mysql

# cd /usr/local/mysql/scripts/

# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

7. 配置環境變數

# echo "mysql_home=/usr/local/mysql" >>/etc/profile

# echo "path=$path:$mysql_home/bin" >> /etc/profile

# source /etc/profile

8. 啟動mysql,並設定開機自啟

# cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld

# chkconfig --add mysqld

# chkconfig mysqld on

# /etc/init.d/mysqld start

9. 設定資料庫登入密碼

# mysqladmin -uroot password '

123456

'

10. 登入資料庫刪除無用的帳號

# mysql -uroot -p'

123456

'mysql> delete from mysql.user where user=''

; query ok,

2 rows affected (0.00

sec)

mysql> delete from mysql.user where host='

::1'

; query ok,

1 row affected (0.00

sec)

mysql> select

user,host from mysql.user;

+------+----------------------------+

| user | host |

+------+----------------------------+

| root | 127.0.0.1 |

| root | 192-168-7-77 |

| root | localhost |

+------+----------------------------+

3 rows in set (0.00 sec)

CentOS7使用二進位制安裝MySQL5 7

centos使用二進位制安裝mysql5.7 建立mysql使用者 useradd s sbin nologin mysql建立mysql資料庫資料儲存資料夾並設定許可權 mkdir var lib mysql chown r mysql mysql var lib mysql 解壓mysql二進位...

centos7 二進位制安裝mysql5 6

wget如 mysql 5.6.35 linux glibc2.5 x86 64.tar.gz useradd s sbin nologin m mysql s表示指定使用者所用的shell,此處為 sbin nologin 表示不登入。m表示不建立使用者主目錄。tar zxvf mysql 5.6...

CentOS7下二進位制檔案安裝MySQL5 6

1.檢視已裝包 root host2 rpm qa grep mysql mysql libs 5.1.71 1.el6.x86 64 root host2 root host2 解除安裝 root host2 rpm e mysql libs 5.1.71 1.el6.x86 64 如果失敗,可能...