1. 程式人生 > >Linux MySQL5.7.18安裝手冊

Linux MySQL5.7.18安裝手冊

1.安裝依賴包

yum install libaio library -y

2.新建使用者組和使用者

groupadd mysql
useradd mysql -g mysql

3.解壓到data下面

tar -zxvf /data/software/mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz -C /data

4 重新命名

mv mysql-5.7.18-linux-glibc2.5-x86_64/ mysql

5.安裝

cd mysql/
mkdir data

6.更改所有者以及授權755許可權

cd ../
chown -R mysql:mysql mysql/
chmod -R 755 mysql/
cd mysql
./bin/mysqld --user=mysql --basedir=/data/mysql --datadir=/data/mysql/data –initialize

7.測試

執行

 ./support-files/mysql.server start

如果提示下面錯誤

./support-files/mysql.server: line 239: my_print_defaults: command not found
./support-files/mysql.server: line 259: cd: /usr/local/mysql: No such file or directory
Starting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)

那就正常了

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

設定環境變數

echo 'PATH=/data/mysql/bin/:$PATH' >>/etc/profile
source /etc/profile

8.配置my.cnf下面是my.cnf的具體配置

[client]
socket =/data/mysql/mysql.sock
port=3306
[mysql]
default-character-set=utf8
[mysqld]
basedir=/data/mysql
datadir=/data/mysql/data
port=3306
pid-file=/data/mysql/mysqld.pid
skip-name-resolve
socket = /data/mysql/mysql.sock
character-set-server=utf8
default-storage-engine=INNODB
explicit_defaults_for_timestamp = true
server-id=1
skip-grant-tables=1

9.修改密碼接下來就是重點了修改密碼,需要修改兩次,一次authentication_string,一次 password

update mysql.user set authentication_string=password('[email protected]') where user='root' and Host = 'localhost';
flush privileges;

特別提醒注意的一點是,新版的mysql資料庫下的user表中已經沒有Password欄位了
而是將加密後的使用者密碼儲存於authentication_string欄位
然後把之前的配置skip-grant-tables=1去掉,重新啟動mysql
上面是多條件精確更改資料庫密碼,也可以執行下面精簡版本

ALTER USER 'root'@'localhost' IDENTIFIED BY '[email protected]';
flush privileges;

10 新增使用者並授權

grant all privileges on *.* to ‘vv’@'%' identified by '[email protected]';
flush privileges;